diff options
Diffstat (limited to 'src/passes/SimplifyLocals.cpp')
-rw-r--r-- | src/passes/SimplifyLocals.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/passes/SimplifyLocals.cpp b/src/passes/SimplifyLocals.cpp index 85c719d4c..ca3d714f4 100644 --- a/src/passes/SimplifyLocals.cpp +++ b/src/passes/SimplifyLocals.cpp @@ -302,6 +302,20 @@ struct SimplifyLocals Expression** currp) { Expression* curr = *currp; + // Expressions that may throw cannot be sinked into 'try'. At the start of + // 'try', we drop all sinkables that may throw. + if (curr->is<Try>()) { + std::vector<Index> invalidated; + for (auto& sinkable : self->sinkables) { + if (sinkable.second.effects.throws) { + invalidated.push_back(sinkable.first); + } + } + for (auto index : invalidated) { + self->sinkables.erase(index); + } + } + EffectAnalyzer effects(self->getPassOptions(), self->getModule()->features); if (effects.checkPre(curr)) { self->checkInvalidations(effects); |