Skip to content

wasm: order funclets in RPO by funclet index#130013

Open
AndyAyersMS wants to merge 1 commit into
dotnet:mainfrom
AndyAyersMS:wasm-r2r-funclet-rpo-order
Open

wasm: order funclets in RPO by funclet index#130013
AndyAyersMS wants to merge 1 commit into
dotnet:mainfrom
AndyAyersMS:wasm-r2r-funclet-rpo-order

Conversation

@AndyAyersMS

Copy link
Copy Markdown
Member

Ensure the RPO/preorder matches the funclet emission order.

So the RPO/preorder matches the order funclets are emitted in,
keeping the codegen control-flow cursor monotonic.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 30, 2026 01:25
@github-actions github-actions Bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Jun 30, 2026
@AndyAyersMS

Copy link
Copy Markdown
Member Author

@adamperlin PTAL
fyi @dotnet/wasm-contrib

Fixes some JIT asserts in Pri1 tests where EH clauses require sorting.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

@AndyAyersMS AndyAyersMS requested a review from adamperlin June 30, 2026 01:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adjusts wasm JIT control-flow layout so funclet ordering in the computed RPO/preorder aligns with the order wasm codegen emits funclets, reducing the chance of mismatches between interval/cursor indexing and physical block traversal.

Changes:

  • Sort wasm DFS funclet entry blocks by descending funclet index (so reverse-postorder yields increasing funclet index).
  • Add a DEBUG-only verification that the physical Blocks() order matches assigned bbPreorderNum after the wasm block reordering.

Comment on lines +139 to +143
// 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);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants