Skip to content

JIT/wasm: keep unreachable in-try blocks attached to their try entry#129716

Open
AndyAyersMS wants to merge 2 commits into
dotnet:mainfrom
AndyAyersMS:fix-wasm-control-flow-b27824
Open

JIT/wasm: keep unreachable in-try blocks attached to their try entry#129716
AndyAyersMS wants to merge 2 commits into
dotnet:mainfrom
AndyAyersMS:fix-wasm-control-flow-b27824

Conversation

@AndyAyersMS

Copy link
Copy Markdown
Member

Inject unreachable in-try blocks as successors of the try entry in VisitWasmSuccs so the wasm DFS visits them and the layout pass keeps them inside the try region; otherwise they end up past fgFirstFuncletBB and break EH-contiguity (b27824).

Inject unreachable in-try blocks as successors of the try entry in
VisitWasmSuccs so the wasm DFS visits them and the layout pass keeps
them inside the try region; otherwise they end up past
fgFirstFuncletBB and break EH-contiguity (b27824).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 22, 2026 20:40
@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 22, 2026
@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

Copy link
Copy Markdown
Member Author

Yet another wasm control flow fix (hopefully the last of these, barring async). We may have unreachable blocks in a try (say inner trys). We need to place these properly for wasm. Pretend they are reachable from the enclosing try entry (like we do for throw helpers).

@adamperlin PTAL
fyi @dotnet/jit-contrib

With this all the Pri-1 tests under JIT pass for me (or are properly skipped) when the test assemblies are built R2R.

@AndyAyersMS AndyAyersMS requested a review from adamperlin June 22, 2026 20:42

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

This PR updates the WASM-specific successor enumeration used by the JIT’s DFS/layout machinery so that certain “unreachable” blocks inside a try region (notably, blocks with no recorded predecessors) are still discovered during WASM DFS. This helps keep those blocks laid out within their try region to preserve EH contiguity.

Changes:

  • Extend FgWasm::VisitWasmSuccs to additionally visit unreachable in-try blocks as successors of the try entry.
  • Filter injected blocks to avoid throw helpers and blocks not in the same EH region as the try entry.

Comment thread src/coreclr/jit/fgwasm.h Outdated
Comment thread src/coreclr/jit/fgwasm.h
Move the per-try-entry scan from FgWasm::VisitWasmSuccs to
FlowGraphTryRegions::Build, which now populates a vector of in-try
blocks that won't be reached by the DFS. The wasm successor enumerator
just walks that vector.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@AndyAyersMS

Copy link
Copy Markdown
Member Author

I have another EH fix I'm working on that I'll add here shortly.

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