summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/passes/Outlining.cpp8
-rw-r--r--src/wasm/wasm-ir-builder.cpp12
2 files changed, 16 insertions, 4 deletions
diff --git a/src/passes/Outlining.cpp b/src/passes/Outlining.cpp
index 429511557..b86e6cd17 100644
--- a/src/passes/Outlining.cpp
+++ b/src/passes/Outlining.cpp
@@ -304,6 +304,14 @@ struct Outlining : public Pass {
// Position the outlined functions first in the functions vector to make
// the outlining lit tests far more readable.
moveOutlinedFunctions(module, substrings.size());
+
+ // Because we visit control flow in stringified order rather than normal
+ // postorder, IRBuilder is not able to properly track branches, so it may
+ // not have finalized blocks with the correct types. ReFinalize now to fix
+ // any issues.
+ PassRunner runner(getPassRunner());
+ runner.add(std::make_unique<ReFinalize>());
+ runner.run();
}
Name addOutlinedFunction(Module* module,
diff --git a/src/wasm/wasm-ir-builder.cpp b/src/wasm/wasm-ir-builder.cpp
index 0d46156be..5253c91ee 100644
--- a/src/wasm/wasm-ir-builder.cpp
+++ b/src/wasm/wasm-ir-builder.cpp
@@ -972,7 +972,12 @@ Result<> IRBuilder::visitEnd() {
block->type = blockType;
return block;
}
- return builder.makeBlock(label, {curr}, blockType);
+ auto* block = builder.makeBlock();
+ block->name = label;
+ block->list.push_back(curr);
+ block->finalize(blockType,
+ scope.labelUsed ? Block::HasBreak : Block::NoBreak);
+ return block;
};
if (auto* func = scope.getFunction()) {
@@ -985,9 +990,8 @@ Result<> IRBuilder::visitEnd() {
} else if (auto* block = scope.getBlock()) {
assert(*expr == block);
block->name = scope.label;
- // TODO: Track branches so we can know whether this block is a target and
- // finalize more efficiently.
- block->finalize(block->type);
+ block->finalize(block->type,
+ scope.labelUsed ? Block::HasBreak : Block::NoBreak);
push(block);
} else if (auto* loop = scope.getLoop()) {
loop->body = *expr;