summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/pass.h5
-rw-r--r--src/passes/pass.cpp25
-rw-r--r--src/tools/optimization-options.h8
3 files changed, 38 insertions, 0 deletions
diff --git a/src/pass.h b/src/pass.h
index 36d49f7b7..973773c49 100644
--- a/src/pass.h
+++ b/src/pass.h
@@ -226,6 +226,8 @@ struct PassOptions {
// Arbitrary string arguments from the commandline, which we forward to
// passes.
std::unordered_map<std::string, std::string> arguments;
+ // Passes to skip and not run.
+ std::unordered_set<std::string> passesToSkip;
// Effect info computed for functions. One pass can generate this and then
// other passes later can benefit from it. It is up to the sequence of passes
@@ -386,6 +388,9 @@ private:
// Whether this pass runner has run. A pass runner should only be run once.
bool ran = false;
+ // Passes in |options.passesToSkip| that we have seen and skipped.
+ std::unordered_set<std::string> skippedPasses;
+
void runPass(Pass* pass);
void runPassOnFunction(Pass* pass, Function* func);
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
diff --git a/src/tools/optimization-options.h b/src/tools/optimization-options.h
index 698d3305e..c87530536 100644
--- a/src/tools/optimization-options.h
+++ b/src/tools/optimization-options.h
@@ -277,6 +277,14 @@ struct OptimizationOptions : public ToolOptions {
Options::Arguments::Zero,
[this](Options*, const std::string&) {
passOptions.zeroFilledMemory = true;
+ })
+ .add("--skip-pass",
+ "-sp",
+ "Skip a pass (do not run it)",
+ OptimizationOptionsCategory,
+ Options::Arguments::One,
+ [this](Options*, const std::string& pass) {
+ passOptions.passesToSkip.insert(pass);
});
// add passes in registry