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 | |
parent | 39afd2a64d72b251fc2da067d338d826b06985b7 (diff) | |
download | binaryen-7ce2aefd8e14d6507fbe4abdcbbba9b0507944f0.tar.gz binaryen-7ce2aefd8e14d6507fbe4abdcbbba9b0507944f0.tar.bz2 binaryen-7ce2aefd8e14d6507fbe4abdcbbba9b0507944f0.zip |
optimize --vacuum a little
-rw-r--r-- | src/passes/Vacuum.cpp | 8 | ||||
-rw-r--r-- | test/unit.fromasm | 1 | ||||
-rw-r--r-- | test/unit.fromasm.imprecise | 1 |
3 files changed, 10 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); + } + } } }; diff --git a/test/unit.fromasm b/test/unit.fromasm index 0a4b39d25..0b43f14fc 100644 --- a/test/unit.fromasm +++ b/test/unit.fromasm @@ -272,6 +272,7 @@ ) ) (func $blocker + (nop) ) (func $frem (result f64) (return diff --git a/test/unit.fromasm.imprecise b/test/unit.fromasm.imprecise index e146f60c4..f5ba55d90 100644 --- a/test/unit.fromasm.imprecise +++ b/test/unit.fromasm.imprecise @@ -266,6 +266,7 @@ ) ) (func $blocker + (nop) ) (func $frem (result f64) (return |