diff options
author | Sam Clegg <sbc@chromium.org> | 2020-04-10 19:48:09 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-10 16:48:09 -0700 |
commit | 7126b2c70d2e087c0e6af463f963d6e84326ecb6 (patch) | |
tree | ef8b3e05103c6bc8026b6d0e2f49ba6a894c5000 /src | |
parent | 6a51af5d858b6d3378749d17065c44cf50b62a26 (diff) | |
download | binaryen-7126b2c70d2e087c0e6af463f963d6e84326ecb6.tar.gz binaryen-7126b2c70d2e087c0e6af463f963d6e84326ecb6.tar.bz2 binaryen-7126b2c70d2e087c0e6af463f963d6e84326ecb6.zip |
Remove redundant vacume pass. Followup on #2741 (#2747)
Based on freedback in #2741 it looks like we can use the existing
`simplify-globals-optimizing` pass to trigger this cleanups we need.
Diffstat (limited to 'src')
-rw-r--r-- | src/passes/SimplifyGlobals.cpp | 23 | ||||
-rw-r--r-- | src/passes/pass.cpp | 1 |
2 files changed, 19 insertions, 5 deletions
diff --git a/src/passes/SimplifyGlobals.cpp b/src/passes/SimplifyGlobals.cpp index 71aafa491..a8012aa44 100644 --- a/src/passes/SimplifyGlobals.cpp +++ b/src/passes/SimplifyGlobals.cpp @@ -167,20 +167,35 @@ private: }; struct GlobalSetRemover : public WalkerPass<PostWalker<GlobalSetRemover>> { - GlobalSetRemover(NameSet* toRemove) : toRemove(toRemove) {} + GlobalSetRemover(const NameSet* toRemove, bool optimize) + : toRemove(toRemove), optimize(optimize) {} bool isFunctionParallel() override { return true; } - GlobalSetRemover* create() override { return new GlobalSetRemover(toRemove); } + GlobalSetRemover* create() override { + return new GlobalSetRemover(toRemove, optimize); + } void visitGlobalSet(GlobalSet* curr) { if (toRemove->count(curr->name) != 0) { ExpressionManipulator::nop(curr); + nopped = true; + } + } + + void visitFunction(Function* curr) { + if (nopped && optimize) { + PassRunner runner(getModule(), getPassRunner()->options); + runner.setIsNested(true); + runner.addDefaultFunctionOptimizationPasses(); + runner.runOnFunction(curr); } } private: - NameSet* toRemove; + const NameSet* toRemove; + bool optimize; + bool nopped = false; }; } // anonymous namespace @@ -247,7 +262,7 @@ struct SimplifyGlobals : public Pass { info.written = false; } } - GlobalSetRemover(&unreadGlobals).run(runner, module); + GlobalSetRemover(&unreadGlobals, optimize).run(runner, module); } void preferEarlierImports() { diff --git a/src/passes/pass.cpp b/src/passes/pass.cpp index 4da870ae9..733b61467 100644 --- a/src/passes/pass.cpp +++ b/src/passes/pass.cpp @@ -483,7 +483,6 @@ void PassRunner::addDefaultGlobalOptimizationPostPasses() { } else { add("simplify-globals"); } - add("vacuum"); // simplify-globals can generate extra nops add("remove-unused-module-elements"); // may allow more inlining/dae/etc., need --converge for that add("directize"); |