diff options
-rw-r--r-- | src/passes/CoalesceLocals.cpp | 6 | ||||
-rw-r--r-- | test/passes/coalesce-locals.txt | 10 | ||||
-rw-r--r-- | test/passes/coalesce-locals.wast | 10 |
3 files changed, 25 insertions, 1 deletions
diff --git a/src/passes/CoalesceLocals.cpp b/src/passes/CoalesceLocals.cpp index f2f26f96a..3127b429c 100644 --- a/src/passes/CoalesceLocals.cpp +++ b/src/passes/CoalesceLocals.cpp @@ -168,7 +168,11 @@ struct CoalesceLocals : public WalkerPass<CFGWalker<CoalesceLocals, Visitor<Coal auto* curr = (*currp)->cast<SetLocal>(); // if in unreachable code, ignore if (!self->currBasicBlock) { - ExpressionManipulator::nop(curr); + if (curr->isTee()) { + ExpressionManipulator::convert<SetLocal, Unreachable>(curr); + } else { + ExpressionManipulator::nop(curr); + } return; } self->currBasicBlock->contents.actions.emplace_back(Action::Set, curr->index, currp); diff --git a/test/passes/coalesce-locals.txt b/test/passes/coalesce-locals.txt index 08573a790..fb590f662 100644 --- a/test/passes/coalesce-locals.txt +++ b/test/passes/coalesce-locals.txt @@ -931,4 +931,14 @@ (nop) ) ) + (func $nop-in-unreachable (type $2) + (local $0 i32) + (block $block + (unreachable) + (i32.store + (unreachable) + (unreachable) + ) + ) + ) ) diff --git a/test/passes/coalesce-locals.wast b/test/passes/coalesce-locals.wast index 26d90ff49..059395f56 100644 --- a/test/passes/coalesce-locals.wast +++ b/test/passes/coalesce-locals.wast @@ -954,4 +954,14 @@ (set_local $a (get_local $a)) ) ) + (func $nop-in-unreachable + (local $x i32) + (block + (unreachable) + (i32.store + (get_local $x) + (tee_local $x (i32.const 0)) + ) + ) + ) ) |