From 70d862dfc8256551af784188f850325a10d1ac7a Mon Sep 17 00:00:00 2001 From: Katelyn Gadd Date: Tue, 17 Mar 2026 11:53:03 -0700 Subject: [PATCH] Insert r2r ind cell at the end of the args list instead of after 'this' when morphing for wasm --- src/coreclr/jit/morph.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/coreclr/jit/morph.cpp b/src/coreclr/jit/morph.cpp index 0531aef7d53e6c..7360b98dfc6483 100644 --- a/src/coreclr/jit/morph.cpp +++ b/src/coreclr/jit/morph.cpp @@ -1780,9 +1780,14 @@ void CallArgs::AddFinalArgsAndDetermineABIInfo(Compiler* comp, GenTreeCall* call // Push the stub address onto the list of arguments. NewCallArg indirCellAddrArg = NewCallArg::Primitive(indirectCellAddress).WellKnown(WellKnownArg::R2RIndirectionCell); +#ifdef TARGET_WASM + // On wasm we need to ensure we put the indirection cell address last in LIR, after the SP and formal args. + PushBack(comp, indirCellAddrArg); +#else InsertAfterThisOrFirst(comp, indirCellAddrArg); +#endif // TARGET_WASM } -#endif +#endif // defined(FEATURE_READYTORUN) #if defined(TARGET_WASM) // On WASM, we need to add an initial argument for the stack pointer for managed calls.