diff options
-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) + ) + ) + ) +) + |