Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/coreclr/jit/fgwasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,13 @@ FlowGraphDfsTree* FgWasm::WasmDfs(bool& hasBlocksOnlyReachableViaEH)
}
}

// Sort handler entries by funclet index (descending), so
// that RPO and funclet emission order agree.
//
jitstd::sort(entryBlocks.begin(), entryBlocks.end(), [comp](BasicBlock* a, BasicBlock* b) {
return comp->funGetFuncIdx(a) > comp->funGetFuncIdx(b);
Comment thread
AndyAyersMS marked this conversation as resolved.
});

// Also look for any non-funclet entry block that is only reachable EH.
// These should have been connected up to special Wasm switches by fgWasmEhFlow.
// If not, something is wrong.
Expand Down Expand Up @@ -1771,6 +1778,25 @@ PhaseStatus Compiler::fgWasmControlFlow()
//
fgIndexToBlockMap = initialLayout;

// Verify the physical block order (what codegen walks) agrees with the assigned
// preorder numbers (what the wasm intervals / codegen cursor are keyed on).
//
#ifdef DEBUG
{
unsigned order = 0;
for (BasicBlock* const block : Blocks())
{
if (block->bbPreorderNum != order)
{
JITDUMP("Blocks out of order: " FMT_BB " has order %u, but bbPreorderNum=%u\n", block->bbNum, order,
block->bbPreorderNum);
}
assert((block->bbPreorderNum == order) && "block order disagrees with preorder num");
order++;
}
}
#endif // DEBUG

JITDUMPEXEC(fgDumpWasmControlFlow());
JITDUMPEXEC(fgDumpWasmControlFlowDot());

Expand Down
Loading