diff options
author | Alon Zakai <alonzakai@gmail.com> | 2017-08-28 11:26:38 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2017-08-28 11:26:38 -0700 |
commit | 3c8be1c57c3c30168d795e46a4389ec878156215 (patch) | |
tree | 9dc686ef59e413da587a785ae1975c063a3b0523 /src | |
parent | 8c89a7baae740013b038865fc4e290439b91eb6f (diff) | |
download | binaryen-3c8be1c57c3c30168d795e46a4389ec878156215.tar.gz binaryen-3c8be1c57c3c30168d795e46a4389ec878156215.tar.bz2 binaryen-3c8be1c57c3c30168d795e46a4389ec878156215.zip |
fix remove-unused-brs bug with merging br_ifs with unreachable code
Diffstat (limited to 'src')
-rw-r--r-- | src/passes/RemoveUnusedBrs.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/passes/RemoveUnusedBrs.cpp b/src/passes/RemoveUnusedBrs.cpp index e627ce138..e307ec414 100644 --- a/src/passes/RemoveUnusedBrs.cpp +++ b/src/passes/RemoveUnusedBrs.cpp @@ -482,9 +482,11 @@ struct RemoveUnusedBrs : public WalkerPass<PostWalker<RemoveUnusedBrs>> { // a "selectified" condition that executes both. for (Index i = 0; i < list.size() - 1; i++) { auto* br1 = list[i]->dynCast<Break>(); - if (!br1 || !br1->condition) continue; + // avoid unreachable brs, as they are dead code anyhow, and after merging + // them the outer scope could need type changes + if (!br1 || !br1->condition || br1->type == unreachable) continue; auto* br2 = list[i + 1]->dynCast<Break>(); - if (!br2 || !br2->condition) continue; + if (!br2 || !br2->condition || br2->type == unreachable) continue; if (br1->name == br2->name) { assert(!br1->value && !br2->value); if (!EffectAnalyzer(passOptions, br2->condition).hasSideEffects()) { |