diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/wasm-ir-builder.h | 33 | ||||
-rw-r--r-- | src/wasm/wasm-ir-builder.cpp | 11 |
2 files changed, 30 insertions, 14 deletions
diff --git a/src/wasm-ir-builder.h b/src/wasm-ir-builder.h index addbd1a30..3c4a52bea 100644 --- a/src/wasm-ir-builder.h +++ b/src/wasm-ir-builder.h @@ -311,9 +311,11 @@ private: ScopeCtx() : scope(NoScope{}) {} ScopeCtx(Scope scope) : scope(scope) {} - ScopeCtx(Scope scope, Name label) : scope(scope), label(label) {} - ScopeCtx(Scope scope, Name label, Name branchLabel) - : scope(scope), label(label), branchLabel(branchLabel) {} + ScopeCtx(Scope scope, Name label, bool labelUsed) + : scope(scope), label(label), labelUsed(labelUsed) {} + ScopeCtx(Scope scope, Name label, bool labelUsed, Name branchLabel) + : scope(scope), label(label), branchLabel(branchLabel), + labelUsed(labelUsed) {} static ScopeCtx makeFunc(Function* func) { return ScopeCtx(FuncScope{func}); @@ -324,20 +326,29 @@ private: static ScopeCtx makeIf(If* iff, Name originalLabel = {}) { return ScopeCtx(IfScope{iff, originalLabel}); } - static ScopeCtx makeElse(If* iff, Name originalLabel, Name label) { - return ScopeCtx(ElseScope{iff, originalLabel}, label); + static ScopeCtx + makeElse(If* iff, Name originalLabel, Name label, bool labelUsed) { + return ScopeCtx(ElseScope{iff, originalLabel}, label, labelUsed); } static ScopeCtx makeLoop(Loop* loop) { return ScopeCtx(LoopScope{loop}); } static ScopeCtx makeTry(Try* tryy, Name originalLabel = {}) { return ScopeCtx(TryScope{tryy, originalLabel}); } - static ScopeCtx - makeCatch(Try* tryy, Name originalLabel, Name label, Name branchLabel) { - return ScopeCtx(CatchScope{tryy, originalLabel}, label, branchLabel); + static ScopeCtx makeCatch(Try* tryy, + Name originalLabel, + Name label, + bool labelUsed, + Name branchLabel) { + return ScopeCtx( + CatchScope{tryy, originalLabel}, label, labelUsed, branchLabel); } - static ScopeCtx - makeCatchAll(Try* tryy, Name originalLabel, Name label, Name branchLabel) { - return ScopeCtx(CatchAllScope{tryy, originalLabel}, label, branchLabel); + static ScopeCtx makeCatchAll(Try* tryy, + Name originalLabel, + Name label, + bool labelUsed, + Name branchLabel) { + return ScopeCtx( + CatchAllScope{tryy, originalLabel}, label, labelUsed, branchLabel); } static ScopeCtx makeTryTable(TryTable* trytable, Name originalLabel = {}) { return ScopeCtx(TryTableScope{trytable, originalLabel}); diff --git a/src/wasm/wasm-ir-builder.cpp b/src/wasm/wasm-ir-builder.cpp index ccd2ee77a..6322a5786 100644 --- a/src/wasm/wasm-ir-builder.cpp +++ b/src/wasm/wasm-ir-builder.cpp @@ -810,10 +810,11 @@ Result<> IRBuilder::visitElse() { } auto originalLabel = scope.getOriginalLabel(); auto label = scope.label; + auto labelUsed = scope.labelUsed; auto expr = finishScope(); CHECK_ERR(expr); iff->ifTrue = *expr; - pushScope(ScopeCtx::makeElse(iff, originalLabel, label)); + pushScope(ScopeCtx::makeElse(iff, originalLabel, label, labelUsed)); return Ok{}; } @@ -830,6 +831,7 @@ Result<> IRBuilder::visitCatch(Name tag) { } auto originalLabel = scope.getOriginalLabel(); auto label = scope.label; + auto labelUsed = scope.labelUsed; auto branchLabel = scope.branchLabel; auto expr = finishScope(); CHECK_ERR(expr); @@ -839,7 +841,8 @@ Result<> IRBuilder::visitCatch(Name tag) { tryy->catchBodies.push_back(*expr); } tryy->catchTags.push_back(tag); - pushScope(ScopeCtx::makeCatch(tryy, originalLabel, label, branchLabel)); + pushScope( + ScopeCtx::makeCatch(tryy, originalLabel, label, labelUsed, branchLabel)); // Push a pop for the exception payload. auto params = wasm.getTag(tag)->sig.params; if (params != Type::none) { @@ -861,6 +864,7 @@ Result<> IRBuilder::visitCatchAll() { } auto originalLabel = scope.getOriginalLabel(); auto label = scope.label; + auto labelUsed = scope.labelUsed; auto branchLabel = scope.branchLabel; auto expr = finishScope(); CHECK_ERR(expr); @@ -869,7 +873,8 @@ Result<> IRBuilder::visitCatchAll() { } else { tryy->catchBodies.push_back(*expr); } - pushScope(ScopeCtx::makeCatchAll(tryy, originalLabel, label, branchLabel)); + pushScope( + ScopeCtx::makeCatchAll(tryy, originalLabel, label, labelUsed, branchLabel)); return Ok{}; } |