diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ir/effects.h | 10 | ||||
-rw-r--r-- | src/passes/SimplifyLocals.cpp | 10 |
2 files changed, 15 insertions, 5 deletions
diff --git a/src/ir/effects.h b/src/ir/effects.h index 4f3af012f..55c78f05a 100644 --- a/src/ir/effects.h +++ b/src/ir/effects.h @@ -446,8 +446,16 @@ struct EffectAnalyzer if (tryDepth == 0) { throws = true; } + if (!ignoreImplicitTraps) { // rethrow traps when the arg is null + implicitTrap = true; + } + } + void visitBrOnExn(BrOnExn* curr) { + breakNames.insert(curr->name); + if (!ignoreImplicitTraps) { // br_on_exn traps when the arg is null + implicitTrap = true; + } } - void visitBrOnExn(BrOnExn* curr) { breakNames.insert(curr->name); } void visitNop(Nop* curr) {} void visitUnreachable(Unreachable* curr) { branches = true; } void visitPush(Push* curr) { calls = true; } diff --git a/src/passes/SimplifyLocals.cpp b/src/passes/SimplifyLocals.cpp index 23ab1bc92..2f269a00d 100644 --- a/src/passes/SimplifyLocals.cpp +++ b/src/passes/SimplifyLocals.cpp @@ -126,8 +126,7 @@ struct SimplifyLocals Expression** currp) { // Main processing. auto* curr = *currp; - if (curr->is<Break>()) { - auto* br = curr->cast<Break>(); + if (auto* br = curr->dynCast<Break>()) { if (br->value) { // value means the block already has a return value self->unoptimizableBlocks.insert(br->name); @@ -147,6 +146,10 @@ struct SimplifyLocals self->unoptimizableBlocks.insert(target); } // TODO: we could use this info to stop gathering data on these blocks + } else if (auto* br = curr->dynCast<BrOnExn>()) { + // We cannot optimize the block this targets to have a return value, as + // the br_on_exn doesn't support a change to the block's type + self->unoptimizableBlocks.insert(br->name); } self->sinkables.clear(); } @@ -162,10 +165,9 @@ struct SimplifyLocals static void doNoteIfTrue(SimplifyLocals<allowTee, allowStructure, allowNesting>* self, Expression** currp) { - auto* iff = (*currp)->dynCast<If>(); + auto* iff = (*currp)->cast<If>(); if (iff->ifFalse) { // We processed the ifTrue side of this if-else, save it on the stack. - assert((*currp)->cast<If>()->ifFalse); self->ifStack.push_back(std::move(self->sinkables)); } else { // This is an if without an else. |