You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[wasm][R2R] JIT asserts "block order disagrees with preorder num" when an unremovable block becomes unreachable #136041
The Wasm JIT asserts in Wasm control flow (src/coreclr/jit/fgwasm.cpp) when the flow graph contains an unreachable block that fgRemoveBlocksOutsideDfsTree could not remove:
Assertion failed '(block->bbPreorderNum == order) && "block order disagrees with preorder num"' in 'AA:TestEntryPoint(int[])' during 'Wasm control flow' (IL size 35; FullOpts)
This reproduces on current main with a checked Wasm crossgen2 JIT.
Compile with crossgen2 --targetos:browser --targetarch:wasm -O using the checked libclrjit_universal_wasm_* JIT.
Analysis
Loop inversion calls fgSplitBlockAtEnd on the loop's preheader, which is the catch handler's entry block. The new preheader (BB12 in the dump) inherits BBF_DONT_REMOVE through CopyFlags.
Value numbering proves p[0] > p[0] false, so the loop and its preheader become unreachable.
Wasm remove unreachable blocks (fgRemoveBlocksOutsideDfsTree) converts the BBF_DONT_REMOVE block to an empty BBJ_THROW but keeps it. The dump shows "1 unreachable blocks were not removed: BB12".
Wasm control flow lays out only the blocks in its DFS, so the kept block has a stale bbPreorderNum, and the debug check that the block list matches preorder numbering fires.
Stopping fgSplitBlockAtEnd from copying BBF_DONT_REMOVE is not a fix by itself: it trips HBtab->ebdTryBeg->HasFlag(BBF_DONT_REMOVE) during loop inversion. The Wasm control-flow pass, or the unreachable-block removal that runs before it, probably needs to handle unreachable blocks that must be kept.
Impact
This is hit in the outerloop R2R_CG2 browser wasm lane by JIT/Regression/Regression_PdbOnly_r_2 (b49322.AA:TestEntryPoint, which has while (checked(m_ul > m_ul)) inside a catch) once static-base helper calls are marked hoistable in #136037: value numbering can then fold the condition. The bug itself is pre-existing; the array-based repro above asserts on main.
Activity
dotnet-policy-service commentedon Oct 19, 2026
Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara
See info in area-owners.md if you want to be subscribed.
dotnet-policy-service commentedon Oct 19, 2026
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.
JIT: clear BBF_DONT_REMOVE on the new preheader in loop inversion (#1…