diff options
Diffstat (limited to 'src/passes/Vacuum.cpp')
-rw-r--r-- | src/passes/Vacuum.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/passes/Vacuum.cpp b/src/passes/Vacuum.cpp index 4a4963291..0e49f19c8 100644 --- a/src/passes/Vacuum.cpp +++ b/src/passes/Vacuum.cpp @@ -87,7 +87,7 @@ struct Vacuum : public WalkerPass<ExpressionStackWalker<Vacuum>> { // Some instructions have special handling in visit*, and we should do // nothing for them here. if (curr->is<Drop>() || curr->is<Block>() || curr->is<If>() || - curr->is<Loop>() || curr->is<Try>()) { + curr->is<Loop>() || curr->is<Try>() || curr->is<TryTable>()) { return curr; } // Check if this expression itself has side effects, ignoring children. @@ -435,6 +435,15 @@ struct Vacuum : public WalkerPass<ExpressionStackWalker<Vacuum>> { } } + void visitTryTable(TryTable* curr) { + // If try_table's body does not throw, the whole try_table can be replaced + // with the try_table's body. + if (!EffectAnalyzer(getPassOptions(), *getModule(), curr->body).throws()) { + replaceCurrent(curr->body); + return; + } + } + void visitFunction(Function* curr) { auto* optimized = optimize(curr->body, curr->getResults() != Type::none, true); |