diff options
author | Alon Zakai <azakai@google.com> | 2023-01-24 14:23:34 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-24 14:23:34 -0800 |
commit | 5aa94e0d2fa397c178fe307537d36846683c22b7 (patch) | |
tree | c176508bfa3318b5e3561bc8258b28ee729b6a1c /src/passes/pass.cpp | |
parent | dd3091c87cc11ffe297632259cad18a64162e68b (diff) | |
download | binaryen-5aa94e0d2fa397c178fe307537d36846683c22b7.tar.gz binaryen-5aa94e0d2fa397c178fe307537d36846683c22b7.tar.bz2 binaryen-5aa94e0d2fa397c178fe307537d36846683c22b7.zip |
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).
Diffstat (limited to 'src/passes/pass.cpp')
-rw-r--r-- | src/passes/pass.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
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<AfterEffectModuleChecker> checker; if (getPassDebug()) { checker = std::unique_ptr<AfterEffectModuleChecker>( @@ -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 |