[Wasm RyuJIT] Handle case where a TYP_STRUCT return has had its type information erased and we are trying to write it to a TYP_STRUCT local#125279
Conversation
|
cc @AndyAyersMS |
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
There was a problem hiding this comment.
Pull request overview
This PR fixes a crash in the Wasm RyuJIT backend's RewriteLocalStackStore function that occurs when a CALL node returns a small struct as a primitive type (e.g., TYP_INT) due to WASM ABI type erasure, but the STORE_LCL_VAR node still has TYP_STRUCT as its type. The crash happened because the code tried to create a STORE_BLK node via gtNewStoreBlkNode, which requires the value to have struct layout information—but the value's type info had been erased to a primitive type.
Changes:
- Modified the
isStructcheck to require both the store destination and the value to beTYP_STRUCT, preventing the code from attempting to create aSTORE_BLKwhen the value has no layout. - In the non-struct
elsebranch, whenstoreTypeisTYP_STRUCT(type mismatch case), the code now uses the value's actual type instead, avoiding theassert(type != TYP_STRUCT)ingtNewStoreIndNode.
|
cc @dotnet/jit-contrib |
…ased and we are trying to write it to a TYP_STRUCT local
Heh, the contract is surprisingly convoluted when it comes to these stores. I think the right logic should be something like: var_types storeType = lclNode->TypeGet();
if ((storeType == TYP_STRUCT) && lclNode->OperIsCopyBlkOp()) {
var_types lclRegType = varDsc->GetRegisterType(lclStore);
if (lclRegType != TYP_UNDEF)
storeType = lclRegType;
} |
I like that a lot better, thanks! It seems to work. |
Addresses part of #125199
Don't love this solution, feedback welcome.