From ddfa483430c35ce81f05a6497cc68536b594c2b3 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Fri, 25 Aug 2017 11:33:12 -0700 Subject: 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 --- src/passes/RemoveUnusedBrs.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') 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> { self->valueCanFlow = true; // start optimistic } else if (curr->is()) { auto* iff = curr->cast(); + 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> { 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); -- cgit v1.2.3