From 7231e619004414c33b30f4a3dd55ff85c69e1406 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Sat, 5 Aug 2017 12:06:22 -0700 Subject: fix merge-blocks bug with replacing an unreachable block with a concrete final element (which is never reached) --- src/passes/MergeBlocks.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src') 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> { // 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; -- cgit v1.2.3