diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/passes/Vacuum.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/passes/Vacuum.cpp b/src/passes/Vacuum.cpp index f0bdd7722..54707fddc 100644 --- a/src/passes/Vacuum.cpp +++ b/src/passes/Vacuum.cpp @@ -414,6 +414,15 @@ struct Vacuum : public WalkerPass<ExpressionStackWalker<Vacuum>> { } } + void visitTry(Try* curr) { + // If try's body does not throw, the whole try-catch can be replaced with + // the try's body. + if (!EffectAnalyzer(getPassOptions(), getModule()->features, curr->body) + .throws) { + replaceCurrent(curr->body); + } + } + void visitFunction(Function* curr) { auto* optimized = optimize(curr->body, curr->sig.results != Type::none, true); |