summaryrefslogtreecommitdiff
path: root/src/wasm-ir-builder.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/wasm-ir-builder.h')
-rw-r--r--src/wasm-ir-builder.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/wasm-ir-builder.h b/src/wasm-ir-builder.h
index d7a1dde87..40689a879 100644
--- a/src/wasm-ir-builder.h
+++ b/src/wasm-ir-builder.h
@@ -259,6 +259,10 @@ private:
struct NoScope {};
struct FuncScope {
Function* func;
+ // Used to determine whether we need to run a fixup after creating the
+ // function.
+ bool hasSyntheticBlock = false;
+ bool hasPop = false;
};
struct BlockScope {
Block* block;
@@ -369,6 +373,27 @@ private:
}
return nullptr;
}
+ void noteSyntheticBlock() {
+ if (auto* funcScope = std::get_if<FuncScope>(&scope)) {
+ funcScope->hasSyntheticBlock = true;
+ }
+ }
+ void notePop() {
+ if (auto* funcScope = std::get_if<FuncScope>(&scope)) {
+ funcScope->hasPop = true;
+ }
+ }
+ bool needsPopFixup() {
+ // If the function has a synthetic block and it has a pop, then it's
+ // possible that the pop is inside the synthetic block and we should run
+ // the fixup. Determining more precisely that a pop is inside the
+ // synthetic block when it is created would be complicated and expensive,
+ // so we are conservative here.
+ if (auto* funcScope = std::get_if<FuncScope>(&scope)) {
+ return funcScope->hasSyntheticBlock && funcScope->hasPop;
+ }
+ return false;
+ }
Block* getBlock() {
if (auto* blockScope = std::get_if<BlockScope>(&scope)) {
return blockScope->block;