diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-10-12 11:32:56 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-12 11:32:56 -0700 |
commit | ada5fb540164823f8dab45330a190479afa24120 (patch) | |
tree | 68f6741458e21413c3b133041de5638c5d152eeb | |
parent | a08ccc3cdc2e53354f0eaeba419655b641b2b056 (diff) | |
download | binaryen-ada5fb540164823f8dab45330a190479afa24120.tar.gz binaryen-ada5fb540164823f8dab45330a190479afa24120.tar.bz2 binaryen-ada5fb540164823f8dab45330a190479afa24120.zip |
handle unreachable tee_local properly in coalesce-locals (#761)
-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)) + ) + ) + ) ) |