diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-09-13 10:41:14 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2016-09-13 10:50:48 -0700 |
commit | 39ed7c6477f24b06e7ec33d03a86d932aa9a6a5f (patch) | |
tree | 9ca557be1384415a732d3130b0e3fd6546af3437 /src | |
parent | b4a77cf9b0780248c1a62c4409899ee1e23573ef (diff) | |
download | binaryen-39ed7c6477f24b06e7ec33d03a86d932aa9a6a5f.tar.gz binaryen-39ed7c6477f24b06e7ec33d03a86d932aa9a6a5f.tar.bz2 binaryen-39ed7c6477f24b06e7ec33d03a86d932aa9a6a5f.zip |
update br type when turning it into a br_if in remove-unused-brs
Diffstat (limited to 'src')
-rw-r--r-- | src/passes/RemoveUnusedBrs.cpp | 3 | ||||
-rw-r--r-- | src/wasm.h | 2 |
2 files changed, 5 insertions, 0 deletions
diff --git a/src/passes/RemoveUnusedBrs.cpp b/src/passes/RemoveUnusedBrs.cpp index 8b7611ec9..86a46374f 100644 --- a/src/passes/RemoveUnusedBrs.cpp +++ b/src/passes/RemoveUnusedBrs.cpp @@ -149,6 +149,7 @@ struct RemoveUnusedBrs : public WalkerPass<PostWalker<RemoveUnusedBrs, Visitor<R // if the br has a value, then if => br_if means we always execute the value, and also the order is value,condition vs condition,value if (canTurnIfIntoBrIf(curr->condition, br->value)) { br->condition = curr->condition; + br->finalize(); replaceCurrent(br); anotherCycle = true; } @@ -408,6 +409,7 @@ struct RemoveUnusedBrs : public WalkerPass<PostWalker<RemoveUnusedBrs, Visitor<R // we are an if-else where the ifTrue is a break without a condition, so we can do this list[i] = ifTrueBreak; ifTrueBreak->condition = iff->condition; + ifTrueBreak->finalize(); ExpressionManipulator::spliceIntoBlock(curr, i + 1, iff->ifFalse); continue; } @@ -416,6 +418,7 @@ struct RemoveUnusedBrs : public WalkerPass<PostWalker<RemoveUnusedBrs, Visitor<R if (ifFalseBreak && !ifFalseBreak->condition && canTurnIfIntoBrIf(iff->condition, ifFalseBreak->value)) { list[i] = ifFalseBreak; ifFalseBreak->condition = Builder(*getModule()).makeUnary(EqZInt32, iff->condition); + ifFalseBreak->finalize(); ExpressionManipulator::spliceIntoBlock(curr, i + 1, iff->ifTrue); continue; } diff --git a/src/wasm.h b/src/wasm.h index d6bdfe91f..ca3c8e5f5 100644 --- a/src/wasm.h +++ b/src/wasm.h @@ -1027,6 +1027,8 @@ public: void finalize() { if (condition) { type = none; + } else { + type = unreachable; } } }; |