diff --git a/src/coreclr/jit/codegencommon.cpp b/src/coreclr/jit/codegencommon.cpp index ae233e5583d6f9..ae6871d7e63060 100644 --- a/src/coreclr/jit/codegencommon.cpp +++ b/src/coreclr/jit/codegencommon.cpp @@ -1529,6 +1529,30 @@ void CodeGen::genExitCode(BasicBlock* block) GetEmitter()->emitDisableGC(); #endif genEmitGSCookieCheck(jmpEpilog); +#ifndef JIT32_GCENCODER + if (jmpEpilog) + { + // Dev10 642944 - + // The GS cookie check created a temp label that has no live + // incoming GC registers, we need to fix that + + unsigned varNum; + LclVarDsc* varDsc; + + /* Figure out which register parameters hold pointers */ + + for (varNum = 0, varDsc = compiler->lvaTable; varNum < compiler->lvaCount && varDsc->lvIsRegArg; + varNum++, varDsc++) + { + noway_assert(varDsc->lvIsParam); + + gcInfo.gcMarkRegPtrVal(varDsc->GetArgReg(), varDsc->TypeGet()); + } + + GetEmitter()->emitThisGCrefRegs = GetEmitter()->emitInitGCrefRegs = gcInfo.gcRegGCrefSetCur; + GetEmitter()->emitThisByrefRegs = GetEmitter()->emitInitByrefRegs = gcInfo.gcRegByrefSetCur; + } +#endif } genReserveEpilog(block); diff --git a/src/coreclr/jit/codegenxarch.cpp b/src/coreclr/jit/codegenxarch.cpp index f6878beaf09743..4102d4c7711150 100644 --- a/src/coreclr/jit/codegenxarch.cpp +++ b/src/coreclr/jit/codegenxarch.cpp @@ -113,38 +113,16 @@ void CodeGen::genEmitGSCookieCheck(bool pushReg) } else { - if (compiler->info.compRetNativeType == TYP_REF) - { - gcInfo.gcRegGCrefSetCur |= RBM_INTRET; - } - else if (compiler->info.compRetNativeType == TYP_BYREF) + ReturnTypeDesc retTypeDesc = compiler->compRetTypeDesc; + const unsigned regCount = retTypeDesc.GetReturnRegCount(); + + for (unsigned i = 0; i < regCount; ++i) { - gcInfo.gcRegByrefSetCur |= RBM_INTRET; + gcInfo.gcMarkRegPtrVal(retTypeDesc.GetABIReturnReg(i, compiler->info.compCallConv), + retTypeDesc.GetReturnRegType(i)); } } } - else - { - // Dev10 642944 - - // The GS cookie check created a temp label that has no live - // incoming GC registers, we need to fix that - - unsigned varNum; - LclVarDsc* varDsc; - - /* Figure out which register parameters hold pointers */ - - for (varNum = 0, varDsc = compiler->lvaTable; varNum < compiler->lvaCount && varDsc->lvIsRegArg; - varNum++, varDsc++) - { - noway_assert(varDsc->lvIsParam); - - gcInfo.gcMarkRegPtrVal(varDsc->GetArgReg(), varDsc->TypeGet()); - } - - GetEmitter()->emitThisGCrefRegs = GetEmitter()->emitInitGCrefRegs = gcInfo.gcRegGCrefSetCur; - GetEmitter()->emitThisByrefRegs = GetEmitter()->emitInitByrefRegs = gcInfo.gcRegByrefSetCur; - } #else assert(GetEmitter()->emitGCDisabled()); #endif