From 68bf64141dc4d35e6ff174fb68ce5bc50ff27c79 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Sat, 29 Oct 2016 11:02:28 -0700 Subject: fix break value removal in merge-blocks: a br_if's type changes without a value, so finalize the node, and remove the drop --- src/passes/MergeBlocks.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/passes/MergeBlocks.cpp b/src/passes/MergeBlocks.cpp index f7fac9594..edfa1336b 100644 --- a/src/passes/MergeBlocks.cpp +++ b/src/passes/MergeBlocks.cpp @@ -116,8 +116,17 @@ struct BreakValueDropper : public ControlFlowWalkervalue && curr->name == origin) { Builder builder(*getModule()); - replaceCurrent(builder.makeSequence(builder.makeDrop(curr->value), curr)); + auto* value = curr->value; curr->value = nullptr; + curr->finalize(); + replaceCurrent(builder.makeSequence(builder.makeDrop(value), curr)); + } + } + + void visitDrop(Drop* curr) { + // if we dropped a br_if whose value we removed, then we are now dropping a (block (drop value) (br_if)) with type none, which does not need a drop + if (curr->value->type == none) { + replaceCurrent(curr->value); } } }; -- cgit v1.2.3