From 5aa94e0d2fa397c178fe307537d36846683c22b7 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Tue, 24 Jan 2023 14:23:34 -0800 Subject: Add a mechanism to skip a pass by name (#5448) For example, -O3 --skip-pass=vacuum will run -O3 normally but it will not run the vacuum pass at all (which normally runs more than once in -O3). --- src/passes/pass.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/passes/pass.cpp') diff --git a/src/passes/pass.cpp b/src/passes/pass.cpp index 373322a51..593023c7c 100644 --- a/src/passes/pass.cpp +++ b/src/passes/pass.cpp @@ -692,6 +692,9 @@ void PassRunner::run() { assert(!ran); ran = true; + // As we run passes, we'll notice which we skip. + skippedPasses.clear(); + static const int passDebug = getPassDebug(); // Emit logging information when asked for. At passDebug level 1+ we log // the main passes, while in 2 we also log nested ones. Note that for @@ -812,6 +815,16 @@ void PassRunner::run() { } flush(); } + + // All the passes the user requested to skip should have been seen, and + // skipped. If not, the user may have had a typo in the name of a pass to + // skip, and we will warn. + for (auto pass : options.passesToSkip) { + if (!skippedPasses.count(pass)) { + std::cerr << "warning: --" << pass << " was requested to be skipped, " + << "but it was not found in the passes that were run.\n"; + } + } } void PassRunner::runOnFunction(Function* func) { @@ -930,6 +943,13 @@ struct AfterEffectModuleChecker { }; void PassRunner::runPass(Pass* pass) { + assert(!pass->isFunctionParallel()); + + if (options.passesToSkip.count(pass->name)) { + skippedPasses.insert(pass->name); + return; + } + std::unique_ptr checker; if (getPassDebug()) { checker = std::unique_ptr( @@ -949,6 +969,11 @@ void PassRunner::runPass(Pass* pass) { void PassRunner::runPassOnFunction(Pass* pass, Function* func) { assert(pass->isFunctionParallel()); + if (options.passesToSkip.count(pass->name)) { + skippedPasses.insert(pass->name); + return; + } + auto passDebug = getPassDebug(); // Add extra validation logic in pass-debug mode 2. The main logic in -- cgit v1.2.3