From 23bfc0a6ee9010f45d2cab13797e5d6b1a7a140f Mon Sep 17 00:00:00 2001 From: Andy Ayers Date: Fri, 20 Feb 2026 12:08:50 -0800 Subject: [PATCH 1/3] [Wasm RyuJit] fix issue in RewriteLocalStackStore Need to capture the original type before bashing to TYP_I_IMPL. --- src/coreclr/jit/regallocwasm.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/coreclr/jit/regallocwasm.cpp b/src/coreclr/jit/regallocwasm.cpp index 237b3e09b93ac9..403b49bde51418 100644 --- a/src/coreclr/jit/regallocwasm.cpp +++ b/src/coreclr/jit/regallocwasm.cpp @@ -331,7 +331,9 @@ void WasmRegAlloc::RewriteLocalStackStore(GenTreeLclVarCommon* lclNode) // TODO-WASM-RA: figure out the address mode story here. Right now this will produce an address not folded // into the store's address mode. We can utilize a contained LEA, but that will require some liveness work. - uint16_t offset = lclNode->GetLclOffs(); + + var_types storeType = lclNode->TypeGet(); + uint16_t offset = lclNode->GetLclOffs(); lclNode->SetOper(GT_LCL_ADDR); lclNode->ChangeType(TYP_I_IMPL); lclNode->AsLclFld()->SetLclOffs(offset); @@ -344,7 +346,7 @@ void WasmRegAlloc::RewriteLocalStackStore(GenTreeLclVarCommon* lclNode) } else { - store = m_compiler->gtNewStoreIndNode(lclNode->TypeGet(), lclNode, value, indFlags); + store = m_compiler->gtNewStoreIndNode(storeType, lclNode, value, indFlags); } CurrentRange().InsertAfter(lclNode, store); CurrentRange().Remove(lclNode); From f2f33abf146bb2c56dc57a70defb409199dd5c29 Mon Sep 17 00:00:00 2001 From: Andy Ayers Date: Fri, 20 Feb 2026 12:45:36 -0800 Subject: [PATCH 2/3] capture layout before bashing too --- src/coreclr/jit/regallocwasm.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/coreclr/jit/regallocwasm.cpp b/src/coreclr/jit/regallocwasm.cpp index 403b49bde51418..d06d23cc042c21 100644 --- a/src/coreclr/jit/regallocwasm.cpp +++ b/src/coreclr/jit/regallocwasm.cpp @@ -332,8 +332,9 @@ void WasmRegAlloc::RewriteLocalStackStore(GenTreeLclVarCommon* lclNode) // TODO-WASM-RA: figure out the address mode story here. Right now this will produce an address not folded // into the store's address mode. We can utilize a contained LEA, but that will require some liveness work. - var_types storeType = lclNode->TypeGet(); - uint16_t offset = lclNode->GetLclOffs(); + var_types storeType = lclNode->TypeGet(); + uint16_t offset = lclNode->GetLclOffs(); + ClassLayout* layout = lclNode->GetLayout(m_compiler); lclNode->SetOper(GT_LCL_ADDR); lclNode->ChangeType(TYP_I_IMPL); lclNode->AsLclFld()->SetLclOffs(offset); @@ -342,7 +343,7 @@ void WasmRegAlloc::RewriteLocalStackStore(GenTreeLclVarCommon* lclNode) GenTreeFlags indFlags = GTF_IND_NONFAULTING | GTF_IND_TGT_NOT_HEAP; if (lclNode->TypeIs(TYP_STRUCT)) { - store = m_compiler->gtNewStoreBlkNode(lclNode->GetLayout(m_compiler), lclNode, value, indFlags); + store = m_compiler->gtNewStoreBlkNode(layout, lclNode, value, indFlags); } else { From 81489d08679948a1379fa65a36b02e6fd03467e0 Mon Sep 17 00:00:00 2001 From: Andy Ayers Date: Fri, 20 Feb 2026 17:37:25 -0800 Subject: [PATCH 3/3] fix check for struct types --- src/coreclr/jit/regallocwasm.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/jit/regallocwasm.cpp b/src/coreclr/jit/regallocwasm.cpp index d06d23cc042c21..4aba471f1c377c 100644 --- a/src/coreclr/jit/regallocwasm.cpp +++ b/src/coreclr/jit/regallocwasm.cpp @@ -341,7 +341,7 @@ void WasmRegAlloc::RewriteLocalStackStore(GenTreeLclVarCommon* lclNode) GenTree* store; GenTreeFlags indFlags = GTF_IND_NONFAULTING | GTF_IND_TGT_NOT_HEAP; - if (lclNode->TypeIs(TYP_STRUCT)) + if (storeType == TYP_STRUCT) { store = m_compiler->gtNewStoreBlkNode(layout, lclNode, value, indFlags); }