summaryrefslogtreecommitdiff
path: root/src/passes/RemoveUnusedBrs.cpp
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2017-08-25 11:33:12 -0700
committerAlon Zakai <alonzakai@gmail.com>2017-08-25 16:04:36 -0700
commitddfa483430c35ce81f05a6497cc68536b594c2b3 (patch)
treecd01ab61d1bb180a052e3af59acbfeeb89604af3 /src/passes/RemoveUnusedBrs.cpp
parentfe618683f2c8762f8817c7a573095a21751b2ed2 (diff)
downloadbinaryen-ddfa483430c35ce81f05a6497cc68536b594c2b3.tar.gz
binaryen-ddfa483430c35ce81f05a6497cc68536b594c2b3.tar.bz2
binaryen-ddfa483430c35ce81f05a6497cc68536b594c2b3.zip
avoid trying to optimize ifs with unreachable conditions in remove-unused-brs, as they are dead code anyhow, and it is pointless to work hard to handle the type changes
Diffstat (limited to 'src/passes/RemoveUnusedBrs.cpp')
-rw-r--r--src/passes/RemoveUnusedBrs.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/passes/RemoveUnusedBrs.cpp b/src/passes/RemoveUnusedBrs.cpp
index d2b7c944f..a3ef15639 100644
--- a/src/passes/RemoveUnusedBrs.cpp
+++ b/src/passes/RemoveUnusedBrs.cpp
@@ -82,6 +82,10 @@ struct RemoveUnusedBrs : public WalkerPass<PostWalker<RemoveUnusedBrs>> {
self->valueCanFlow = true; // start optimistic
} else if (curr->is<If>()) {
auto* iff = curr->cast<If>();
+ if (iff->condition->type == unreachable) {
+ // avoid trying to optimize this, we never reach it anyhow
+ return;
+ }
if (iff->ifFalse) {
assert(self->ifStack.size() > 0);
for (auto* flow : self->ifStack.back()) {
@@ -174,8 +178,7 @@ struct RemoveUnusedBrs : public WalkerPass<PostWalker<RemoveUnusedBrs>> {
if (iff) {
if (iff->condition->type == unreachable) {
- // avoid all the branching, we never reach it anyhow
- *currp = iff->condition;
+ // avoid trying to optimize this, we never reach it anyhow
return;
}
self->pushTask(doVisitIf, currp);