diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-04-20 17:49:02 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2016-04-20 17:52:09 -0700 |
commit | 7ce2aefd8e14d6507fbe4abdcbbba9b0507944f0 (patch) | |
tree | 245a75228bcda9d9ab627186c7252454fcb9ac70 /src | |
parent | 39afd2a64d72b251fc2da067d338d826b06985b7 (diff) | |
download | binaryen-7ce2aefd8e14d6507fbe4abdcbbba9b0507944f0.tar.gz binaryen-7ce2aefd8e14d6507fbe4abdcbbba9b0507944f0.tar.bz2 binaryen-7ce2aefd8e14d6507fbe4abdcbbba9b0507944f0.zip |
optimize --vacuum a little
Diffstat (limited to 'src')
-rw-r--r-- | src/passes/Vacuum.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/passes/Vacuum.cpp b/src/passes/Vacuum.cpp index dfede6d25..863d78f14 100644 --- a/src/passes/Vacuum.cpp +++ b/src/passes/Vacuum.cpp @@ -20,6 +20,7 @@ #include <wasm.h> #include <pass.h> +#include <ast_utils.h> namespace wasm { @@ -41,6 +42,13 @@ struct Vacuum : public WalkerPass<PostWalker<Vacuum, Visitor<Vacuum>>> { if (skip > 0) { list.resize(size - skip); } + if (!curr->name.is()) { + if (list.size() == 1) { + replaceCurrent(list[0]); + } else if (list.size() == 0) { + ExpressionManipulator::nop(curr); + } + } } }; |