summaryrefslogtreecommitdiff
path: root/src/passes/MergeBlocks.cpp
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2017-08-05 12:06:22 -0700
committerAlon Zakai (kripken) <alonzakai@gmail.com>2017-08-05 13:46:09 -0700
commit7231e619004414c33b30f4a3dd55ff85c69e1406 (patch)
treea9fc848274b1bbf65fb2c931a34b26c2279028d9 /src/passes/MergeBlocks.cpp
parentcc193a49fa612142fdea016ed8fe8a527be7c835 (diff)
downloadbinaryen-7231e619004414c33b30f4a3dd55ff85c69e1406.tar.gz
binaryen-7231e619004414c33b30f4a3dd55ff85c69e1406.tar.bz2
binaryen-7231e619004414c33b30f4a3dd55ff85c69e1406.zip
fix merge-blocks bug with replacing an unreachable block with a concrete final element (which is never reached)
Diffstat (limited to 'src/passes/MergeBlocks.cpp')
-rw-r--r--src/passes/MergeBlocks.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/passes/MergeBlocks.cpp b/src/passes/MergeBlocks.cpp
index 4fa2c651e..3627a5b0e 100644
--- a/src/passes/MergeBlocks.cpp
+++ b/src/passes/MergeBlocks.cpp
@@ -294,11 +294,12 @@ struct MergeBlocks : public WalkerPass<PostWalker<MergeBlocks>> {
// here
return outer;
}
+ // we are going to replace the block with the final element, so they should
+ // be identically typed
+ if (block->type != back->type) {
+ return outer;
+ }
child = back;
- // we modified child (which is a reference to a pointer), which modifies curr, which might change its type
- // (e.g. (drop (block (result i32) .. (unreachable)))
- // the child was a block of i32, and is being replaced with an unreachable, so the
- // parent will likely need to be unreachable too
if (outer == nullptr) {
// reuse the block, move it out
block->list.back() = curr;