Skip to content

Commit 19ca5df

Browse files
authored
JIT: Handle x86 gs cookie checks before tailcalls (#121169)
The code path assumed we didn't have tailcalls on x86, but we do see them for `CEE_JMP` specifically. In that case the GS cookie check may need a register in AOT scenarios, so give it one.
1 parent 170acef commit 19ca5df

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/coreclr/jit/codegencommon.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2529,8 +2529,16 @@ regMaskTP CodeGenInterface::genGetGSCookieTempRegs(bool tailCall)
25292529
// Otherwise on x64 (win-x64, SysV and Swift) r9 is never used for return values
25302530
return RBM_R9;
25312531
#elif TARGET_X86
2532-
assert(!tailCall);
2533-
// On x86 it's more difficult: we have only eax, ecx and edx available as volatile
2532+
if (tailCall)
2533+
{
2534+
// For tailcall we may need ecx and edx for args. We could use eax, but
2535+
// leave it free in case the tailcall needs something for the target.
2536+
// Since this is only for explicit tailcalls or CEE_JMP we can just use
2537+
// a callee save.
2538+
return RBM_ESI;
2539+
}
2540+
2541+
// For regular calls we have only eax, ecx and edx available as volatile
25342542
// registers, and all of them may be used for return values (longs + async continuation).
25352543
if (compiler->compIsAsync())
25362544
{

0 commit comments

Comments
 (0)