diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-10-02 16:35:41 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-02 16:35:41 -0700 |
commit | 9046e5fb540c92c7d994ba72893c724415ab371b (patch) | |
tree | a420621c7b95a5d7d1b7a297434a52f386839d54 | |
parent | 31ceb6ef95835952097ecc868eff9bdd7fb17d34 (diff) | |
download | binaryen-9046e5fb540c92c7d994ba72893c724415ab371b.tar.gz binaryen-9046e5fb540c92c7d994ba72893c724415ab371b.tar.bz2 binaryen-9046e5fb540c92c7d994ba72893c724415ab371b.zip |
fix vacuum big where we changed an unreachable node to a nop (#728)
-rw-r--r-- | src/passes/Vacuum.cpp | 6 | ||||
-rw-r--r-- | test/passes/remove-unused-names_vacuum.txt | 8 | ||||
-rw-r--r-- | test/passes/remove-unused-names_vacuum.wast | 11 |
3 files changed, 24 insertions, 1 deletions
diff --git a/src/passes/Vacuum.cpp b/src/passes/Vacuum.cpp index c3fed2328..8d9bb421c 100644 --- a/src/passes/Vacuum.cpp +++ b/src/passes/Vacuum.cpp @@ -177,7 +177,11 @@ struct Vacuum : public WalkerPass<ExpressionStackWalker<Vacuum, Visitor<Vacuum>> if (isConcreteWasmType(curr->type) || EffectAnalyzer(list[0]).hasSideEffects()) { replaceCurrent(list[0]); } else { - ExpressionManipulator::nop(curr); + if (curr->type == unreachable) { + ExpressionManipulator::convert<Block, Unreachable>(curr); + } else { + ExpressionManipulator::nop(curr); + } } } else if (list.size() == 0) { ExpressionManipulator::nop(curr); diff --git a/test/passes/remove-unused-names_vacuum.txt b/test/passes/remove-unused-names_vacuum.txt new file mode 100644 index 000000000..3819fcbec --- /dev/null +++ b/test/passes/remove-unused-names_vacuum.txt @@ -0,0 +1,8 @@ +(module + (memory $0 0) + (type $0 (func (result i32))) + (func $return-i32-but-body-is-unreachable3 (type $0) (result i32) + (local $label i32) + (unreachable) + ) +) diff --git a/test/passes/remove-unused-names_vacuum.wast b/test/passes/remove-unused-names_vacuum.wast new file mode 100644 index 000000000..04b08c332 --- /dev/null +++ b/test/passes/remove-unused-names_vacuum.wast @@ -0,0 +1,11 @@ +(module + (func $return-i32-but-body-is-unreachable3 (result i32) + (local $label i32) + (block ;; without a name here, vaccum had a too-eager bug + (loop $while-in$1 + (br $while-in$1) + ) + ) + ) +) + |