summaryrefslogtreecommitdiff
path: root/src/cfg/Relooper.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/cfg/Relooper.cpp')
-rw-r--r--src/cfg/Relooper.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/cfg/Relooper.cpp b/src/cfg/Relooper.cpp
index 9fcc9c8be..b326d761d 100644
--- a/src/cfg/Relooper.cpp
+++ b/src/cfg/Relooper.cpp
@@ -328,7 +328,12 @@ wasm::Expression* Block::Render(RelooperBuilder& Builder, bool InLoop) {
NextOuter->list.push_back(Outer);
Outer->name = CurrName; // breaking on Outer leads to the content in NextOuter
NextOuter->list.push_back(CurrContent);
- NextOuter->list.push_back(Builder.makeBreak(SwitchLeave));
+ // if this is not a dead end, also need to break to the outside
+ // this is both an optimization, and avoids incorrectness as adding
+ // a brak in unreachable code can make a place look reachable that isn't
+ if (CurrContent->type != wasm::unreachable) {
+ NextOuter->list.push_back(Builder.makeBreak(SwitchLeave));
+ }
// prepare for more nesting
Outer = NextOuter;
} else {