Skip to content

Commit

Permalink
Do not enregister Return SP check (dotnet#59759)
Browse files Browse the repository at this point in the history
  • Loading branch information
kunalspathak authored Sep 29, 2021
1 parent 8dd058a commit cf5c6a4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/coreclr/jit/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4665,7 +4665,8 @@ void Compiler::compCompile(void** methodCodePtr, uint32_t* methodCodeSize, JitFl
#if defined(DEBUG) && defined(TARGET_XARCH)
if (opts.compStackCheckOnRet)
{
lvaReturnSpCheck = lvaGrabTempWithImplicitUse(false DEBUGARG("ReturnSpCheck"));
lvaReturnSpCheck = lvaGrabTempWithImplicitUse(false DEBUGARG("ReturnSpCheck"));
lvaSetVarDoNotEnregister(lvaReturnSpCheck, DoNotEnregisterReason::ReturnSpCheck);
lvaTable[lvaReturnSpCheck].lvType = TYP_I_IMPL;
}
#endif // defined(DEBUG) && defined(TARGET_XARCH)
Expand Down Expand Up @@ -9825,6 +9826,10 @@ void Compiler::EnregisterStats::RecordLocal(const LclVarDsc* varDsc)
m_blockOpRet++;
break;

case DoNotEnregisterReason::ReturnSpCheck:
m_returnSpCheck++;
break;

default:
unreached();
break;
Expand Down Expand Up @@ -9945,6 +9950,7 @@ void Compiler::EnregisterStats::Dump(FILE* fout) const
PRINT_STATS(m_oneAsgRetyping, notEnreg);
PRINT_STATS(m_swizzleArg, notEnreg);
PRINT_STATS(m_blockOpRet, notEnreg);
PRINT_STATS(m_returnSpCheck, notEnreg);

fprintf(fout, "\nAddr exposed details:\n");
if (m_addrExposed == 0)
Expand Down
4 changes: 3 additions & 1 deletion src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,8 @@ enum class DoNotEnregisterReason
StoreBlkSrc, // the local is used as STORE_BLK source.
OneAsgRetyping, // fgMorphOneAsgBlockOp prevents this local from being enregister.
SwizzleArg, // the local is passed using LCL_FLD as another type.
BlockOpRet // the struct is returned and it promoted or there is a cast.
BlockOpRet, // the struct is returned and it promoted or there is a cast.
ReturnSpCheck // the local is used to do SP check
};

enum class AddressExposedReason
Expand Down Expand Up @@ -10301,6 +10302,7 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
unsigned m_oneAsgRetyping;
unsigned m_swizzleArg;
unsigned m_blockOpRet;
unsigned m_returnSpCheck;
unsigned m_liveInOutHndlr;
unsigned m_depField;
unsigned m_noRegVars;
Expand Down
4 changes: 4 additions & 0 deletions src/coreclr/jit/lclvars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2664,6 +2664,10 @@ void Compiler::lvaSetVarDoNotEnregister(unsigned varNum DEBUGARG(DoNotEnregister
JITDUMP("return uses a block op\n");
break;

case DoNotEnregisterReason::ReturnSpCheck:
JITDUMP("Used for SP check\n");
break;

default:
unreached();
break;
Expand Down

0 comments on commit cf5c6a4

Please sign in to comment.