Skip to content

Commit aa745d1

Browse files
committed
Fix AV due to GS cookie check overwriting the continuation return register
1 parent 518a7bf commit aa745d1

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

src/coreclr/jit/codegenxarch.cpp

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -102,19 +102,11 @@ void CodeGen::genEmitGSCookieCheck(bool pushReg)
102102
if (!pushReg)
103103
{
104104
// Non-tail call: we can use any callee trash register that is not
105-
// a return register or contain 'this' pointer (keep alive this), since
106-
// we are generating GS cookie check after a GT_RETURN block.
107-
// Note: On Amd64 System V RDX is an arg register - REG_ARG_2 - as well
108-
// as return register for two-register-returned structs.
109-
if (compiler->lvaKeepAliveAndReportThis() && compiler->lvaGetDesc(compiler->info.compThisArg)->lvIsInReg() &&
110-
(compiler->lvaGetDesc(compiler->info.compThisArg)->GetRegNum() == REG_ARG_0))
111-
{
112-
regGSCheck = REG_ARG_1;
113-
}
114-
else
115-
{
116-
regGSCheck = REG_ARG_0;
117-
}
105+
// a return register or contain 'this' pointer (keep alive this), or
106+
// a continuation register, since we are generating GS cookie check
107+
// after a GT_RETURN block.
108+
// ARG_1 is EDX or RSI, depending on platform. Either way it fits our reqirements
109+
regGSCheck = REG_ARG_1;
118110
}
119111
else
120112
{

0 commit comments

Comments
 (0)