Uh oh!
There was an error while loading. Please reload this page.
[Wasm RyuJit] More crossgen assert fixes - #125102
Conversation
* use gtOverflowEx instead of gtOverflow * not all block stores need null checks * more cases where we don't have putarg stacks * add lowering was bypassing Wasm overflow checking
AndyAyersMS
commented
Mar 3, 2026
We might be able to be even more fine-grained with the null checks. Also not 100% sure yet what to do with all the operand reordering for calls, but this at least tolerates the way Wasm does things. |
There was a problem hiding this comment.
Pull request overview
This PR fixes several assert failures in the WASM RyuJIT cross-compilation codepath ("crossgen assert fixes"):
Changes:
- Replace incorrect
gtOverflow()calls withgtOverflowEx()in WASM-specific lowering and codegen, sincegtOverflow()assertsOperMayOverflow()and these sites can be reached with non-overflow-capable operators (AND, OR, XOR). - Fix overflow checking for
GT_ADDon WASM:LowerAddwas not callingLowerBinaryArithmetic, so theSetMultiplyUsed()calls needed to set up overflow-checking registers were skipped for overflow ADDs. - Guard null checks in
genCodeForCpObjbehind adoNullChecksflag (GTF_EXCEPT && OperMayThrow) since not all block-copy operations need null checks. - Fix asserts in
MovePutArgUpToCall/MovePutArgNodesUpToCallthat assumed nodes must beGT_PUTARG_*orGT_FIELD_LIST, which is not true on WASM whereHAS_FIXED_REGISTER_SET = 0.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/coreclr/jit/lowerwasm.cpp | Use gtOverflowEx() instead of gtOverflow() in LowerBinaryArithmetic for correctness when called with non-overflow-capable operators (AND/OR/XOR) |
src/coreclr/jit/lower.cpp | Fix MovePutArgUpToCall/MovePutArgNodesUpToCall asserts for WASM (no PutArg nodes); add new else branch for plain arg nodes; call LowerBinaryArithmetic from LowerAdd on WASM to fix missing overflow setup for ADD |
src/coreclr/jit/codegenwasm.cpp | Use gtOverflowEx() instead of gtOverflow() in genCodeForBinary; gate null checks in genCodeForCpObj behind doNullChecks for correctness when copies are known safe |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara |
1 similar comment
Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara |
Uh oh!
There was an error while loading. Please reload this page.
SingleAccretion
left a comment
There was a problem hiding this comment.
LGTM modulo comments.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: SingleAccretion <62474226+SingleAccretion@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
src/coreclr/jit/lower.cpp:8056
- In
LowerAdd, theLowerBinaryArithmetic(node)call (line 8049) already invokesContainCheckBinaryinternally (seelowerwasm.cppline 174). The code then falls through to callContainCheckBinary(node)again at line 8055 for WASM. Since WASM'sContainCheckBinaryis an empty no-op, this is functionally harmless but is a redundant double call. Returning early from the WASM block (or not callingContainCheckBinaryagain for WASM) would be cleaner.
#if defined(TARGET_WASM)
if (node->OperIs(GT_ADD))
{
LowerBinaryArithmetic(node);
}
#endif
if (node->OperIs(GT_ADD))
{
ContainCheckBinary(node);
}
AndyAyersMS
commented
Mar 4, 2026
@dotnet/jit-contrib PTAL |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.