diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-05-19 16:13:08 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2016-05-19 16:13:08 -0700 |
commit | 579010855a134a78cab8ed129cbbbe52bd52a380 (patch) | |
tree | 7b9da5de9331ccc2f6084209e136701a80026138 /src | |
parent | fe1bda7da797e5586d39122aec931a8a84df4ac7 (diff) | |
download | binaryen-579010855a134a78cab8ed129cbbbe52bd52a380.tar.gz binaryen-579010855a134a78cab8ed129cbbbe52bd52a380.tar.bz2 binaryen-579010855a134a78cab8ed129cbbbe52bd52a380.zip |
vacuum the top of functions too
Diffstat (limited to 'src')
-rw-r--r-- | src/passes/Vacuum.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/passes/Vacuum.cpp b/src/passes/Vacuum.cpp index 6d6f1490a..1524927ec 100644 --- a/src/passes/Vacuum.cpp +++ b/src/passes/Vacuum.cpp @@ -212,6 +212,18 @@ struct Vacuum : public WalkerPass<PostWalker<Vacuum, Visitor<Vacuum>>> { self->pushTask(visitPre, currp); } + + void visitFunction(Function* curr) { + auto* optimized = optimize(curr->body, curr->result != none); + if (optimized) { + curr->body = optimized; + } else { + ExpressionManipulator::nop(curr->body); + } + if (curr->result == none && !EffectAnalyzer(curr->body).hasSideEffects()) { + ExpressionManipulator::nop(curr->body); + } + } }; static RegisterPass<Vacuum> registerPass("vacuum", "removes obviously unneeded code"); |