1
0
Fork 0
mirror of https://github.com/VSadov/Satori.git synced 2025-06-09 09:34:49 +09:00

JIT: Skip old promotion for retbuf defined locals (#104439)

These locals end up being dependently promoted. Skip them and allow
physical promotion to handle them instead.
This commit is contained in:
Jakob Botsch Nielsen 2024-07-05 13:41:59 +02:00 committed by GitHub
parent 8a99adad39
commit 41d854fd44
Signed by: github
GPG key ID: B5690EEEBB952194
3 changed files with 23 additions and 3 deletions

View file

@ -387,6 +387,19 @@ private:
#endif // DEBUG
}
// If the inline was rejected and returns a retbuffer, then mark that
// local as DNER now so that promotion knows to leave it up to physical
// promotion.
if ((*use)->IsCall())
{
CallArg* retBuffer = (*use)->AsCall()->gtArgs.GetRetBufferArg();
if ((retBuffer != nullptr) && retBuffer->GetNode()->OperIs(GT_LCL_ADDR))
{
m_compiler->lvaSetVarDoNotEnregister(retBuffer->GetNode()->AsLclVarCommon()->GetLclNum()
DEBUGARG(DoNotEnregisterReason::HiddenBufferStructArg));
}
}
#if FEATURE_MULTIREG_RET
// If an inline was rejected and the call returns a struct, we may
// have deferred some work when importing call for cases where the

View file

@ -851,6 +851,12 @@ GenTree* Compiler::impStoreStruct(GenTree* store,
GenTree* destAddr = impGetNodeAddr(store, CHECK_SPILL_ALL, &indirFlags);
NewCallArg newArg = NewCallArg::Primitive(destAddr).WellKnown(wellKnownArgType);
if (destAddr->OperIs(GT_LCL_ADDR))
{
lvaSetVarDoNotEnregister(destAddr->AsLclVarCommon()->GetLclNum()
DEBUGARG(DoNotEnregisterReason::HiddenBufferStructArg));
}
#if !defined(TARGET_ARM)
// Unmanaged instance methods on Windows or Unix X86 need the retbuf arg after the first (this) parameter
if ((TargetOS::IsWindows || compUnixX86Abi()) && srcCall->IsUnmanaged())

View file

@ -2570,9 +2570,11 @@ bool Compiler::StructPromotionHelper::CanPromoteStructVar(unsigned lclNum)
return false;
}
if (varDsc->IsAddressExposed())
if (varDsc->lvDoNotEnregister)
{
JITDUMP(" struct promotion of V%02u is disabled because it has already been marked address exposed\n", lclNum);
// Promoting structs that are marked DNER will result in dependent
// promotion. Allow physical promotion to handle these.
JITDUMP(" struct promotion of V%02u is disabled because it has already been marked DNER\n", lclNum);
return false;
}
@ -3173,7 +3175,6 @@ void Compiler::lvaSetVarDoNotEnregister(unsigned varNum DEBUGARG(DoNotEnregister
break;
case DoNotEnregisterReason::HiddenBufferStructArg:
JITDUMP("it is hidden buffer struct arg\n");
assert(varDsc->IsHiddenBufferStructArg());
break;
case DoNotEnregisterReason::DontEnregStructs:
JITDUMP("struct enregistration is disabled\n");