diff options
Diffstat (limited to 'src/passes/DeadCodeElimination.cpp')
-rw-r--r-- | src/passes/DeadCodeElimination.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/passes/DeadCodeElimination.cpp b/src/passes/DeadCodeElimination.cpp index 3e84a7be1..c30da5428 100644 --- a/src/passes/DeadCodeElimination.cpp +++ b/src/passes/DeadCodeElimination.cpp @@ -161,9 +161,12 @@ struct DeadCodeElimination } else if (auto* tryy = curr->dynCast<Try>()) { // If both try body and catch body are unreachable, there is no need for a // concrete type, which may allow more reduction. + bool allCatchesUnreachable = true; + for (auto* catchBody : tryy->catchBodies) { + allCatchesUnreachable &= catchBody->type == Type::unreachable; + } if (tryy->type != Type::unreachable && - tryy->body->type == Type::unreachable && - tryy->catchBody->type == Type::unreachable) { + tryy->body->type == Type::unreachable && allCatchesUnreachable) { typeUpdater.changeType(tryy, Type::unreachable); } } else { |