summaryrefslogtreecommitdiff
path: root/src/passes/RemoveUnusedBrs.cpp
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2017-09-05 19:26:19 -0700
committerGitHub <noreply@github.com>2017-09-05 19:26:19 -0700
commitc0f21e10a1166829afd34c4fb06366d7430802bb (patch)
tree518bbe8c8746679b3adf678940e52158e77b5ede /src/passes/RemoveUnusedBrs.cpp
parent4f58e1e666cff6f1e61d888279dba42d1be14251 (diff)
downloadbinaryen-c0f21e10a1166829afd34c4fb06366d7430802bb.tar.gz
binaryen-c0f21e10a1166829afd34c4fb06366d7430802bb.tar.bz2
binaryen-c0f21e10a1166829afd34c4fb06366d7430802bb.zip
Return to more structured type rules for block and if (#1148)
* if a block has a concrete final element (or a break with a value), then even if it has an unreachable child, keep it with that concrete type. this means we no longe allow the silly case of a block with an unreachable in the middle and a concrete as the final element while the block is unreachable - after this change, the block would have the type of the final element * if an if has a concrete element in one arm, make it have that type as a result, even if the if condition is unreachable, to parallel block * make type rules for brs and switches simpler, ignore whether they are reachable or not. whether they are dead code should not affect how they influence other types in our IR.
Diffstat (limited to 'src/passes/RemoveUnusedBrs.cpp')
-rw-r--r--src/passes/RemoveUnusedBrs.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/passes/RemoveUnusedBrs.cpp b/src/passes/RemoveUnusedBrs.cpp
index e307ec414..ec7809f48 100644
--- a/src/passes/RemoveUnusedBrs.cpp
+++ b/src/passes/RemoveUnusedBrs.cpp
@@ -394,7 +394,9 @@ struct RemoveUnusedBrs : public WalkerPass<PostWalker<RemoveUnusedBrs>> {
if (list.size() == 1 && curr->name.is()) {
// if this block has just one child, a sub-block, then jumps to the former are jumps to us, really
if (auto* child = list[0]->dynCast<Block>()) {
- if (child->name.is() && child->name != curr->name) {
+ // the two blocks must have the same type for us to update the branch, as otherwise
+ // one block may be unreachable and the other concrete, so one might lack a value
+ if (child->name.is() && child->name != curr->name && child->type == curr->type) {
auto& breaks = breaksToBlock[child];
for (auto* br : breaks) {
newNames[br] = curr->name;