[Wasm RyuJIT] Fix classifier embiggening small structs that are being passed-as a wasm primitive#125278
[Wasm RyuJIT] Fix classifier embiggening small structs that are being passed-as a wasm primitive#125278kg wants to merge 3 commits intodotnet:mainfrom
Conversation
…asm primitive. Addresses part of dotnet#125199
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
There was a problem hiding this comment.
Pull request overview
Adjusts Wasm ABI classification for small structs that are lowered to Wasm primitive types to avoid size/type mismatches during local stack stores (part of #125199).
Changes:
- Compute the ABI passing segment size for lowered structs using the struct’s actual size (capped by the ABI primitive size) instead of always using the primitive size.
| regNumber reg = MakeWasmReg(m_localIndex++, genActualType(abiType)); | ||
| // If the struct is being passed directly as a wasm value, make sure we record | ||
| // the actual size of the struct, not the size of the containing wasm value. | ||
| unsigned segmentSize = passByRef ? genTypeSize(abiType) : min(structLayout->GetSize(), genTypeSize(abiType)); |
There was a problem hiding this comment.
When passByRef is false, using min(structLayout->GetSize(), genTypeSize(abiType)) can silently truncate the recorded segment size if getWasmLowering ever returns a wasm primitive that’s smaller than the actual struct size. That would mask a classifier/EE mismatch and could lead to incorrect copying later; consider using structLayout->GetSize() directly and adding a debug assert that it fits in genTypeSize(abiType) instead of clamping.
| unsigned segmentSize = passByRef ? genTypeSize(abiType) : min(structLayout->GetSize(), genTypeSize(abiType)); | |
| unsigned abiTypeSize = genTypeSize(abiType); | |
| unsigned segmentSize; | |
| if (passByRef) | |
| { | |
| segmentSize = abiTypeSize; | |
| } | |
| else | |
| { | |
| unsigned structSize = structLayout->GetSize(); | |
| assert(structSize <= abiTypeSize); | |
| segmentSize = structSize; | |
| } |
Addresses part of #125199