summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai (kripken) <alonzakai@gmail.com>2017-07-11 09:45:10 -0700
committerAlon Zakai (kripken) <alonzakai@gmail.com>2017-07-11 11:07:46 -0700
commit6159fb42fcd2dae593ee61ebb7e3e163445ae9d0 (patch)
tree1d18ee1367f2ce10594719b335a5a630ad3ce87d /src
parente5ebae7cc965f3272e03cf29cc114c638b00eb3a (diff)
downloadbinaryen-6159fb42fcd2dae593ee61ebb7e3e163445ae9d0.tar.gz
binaryen-6159fb42fcd2dae593ee61ebb7e3e163445ae9d0.tar.bz2
binaryen-6159fb42fcd2dae593ee61ebb7e3e163445ae9d0.zip
fix handling of unreachable br values in merge-blocks
Diffstat (limited to 'src')
-rw-r--r--src/passes/MergeBlocks.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/passes/MergeBlocks.cpp b/src/passes/MergeBlocks.cpp
index 8ffbb345d..2c983d991 100644
--- a/src/passes/MergeBlocks.cpp
+++ b/src/passes/MergeBlocks.cpp
@@ -122,6 +122,11 @@ struct BreakValueDropper : public ControlFlowWalker<BreakValueDropper> {
if (curr->value && curr->name == origin) {
Builder builder(*getModule());
auto* value = curr->value;
+ if (value->type == unreachable) {
+ // the break isn't even reached
+ replaceCurrent(value);
+ return;
+ }
curr->value = nullptr;
curr->finalize();
replaceCurrent(builder.makeSequence(builder.makeDrop(value), curr));
@@ -130,7 +135,8 @@ struct BreakValueDropper : public ControlFlowWalker<BreakValueDropper> {
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) {
+ // likewise, unreachable does not need to be dropped, so we just leave drops of concrete values
+ if (!isConcreteWasmType(curr->value->type)) {
replaceCurrent(curr->value);
}
}