Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JIT: Update type when return temp is freshly created #111948

Merged
merged 18 commits into from
Feb 1, 2025
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -4091,6 +4091,8 @@ class Compiler
unsigned lvaInlineeReturnSpillTemp = BAD_VAR_NUM; // The temp to spill the non-VOID return expression
// in case there are multiple BBJ_RETURN blocks in the inlinee
// or if the inlinee has GC ref locals.

bool lvaInlineeReturnSpillTempFreshlyCreated = false; // True if the temp was freshly created for the inlinee return

#if FEATURE_FIXED_OUT_ARGS
unsigned lvaOutgoingArgSpaceVar = BAD_VAR_NUM; // var that represents outgoing argument space
Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/jit/fgbasic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3562,6 +3562,8 @@ void Compiler::fgFindBasicBlocks()
lvaSetClass(lvaInlineeReturnSpillTemp, retClassHnd);
}
}

lvaInlineeReturnSpillTempFreshlyCreated = true;
}
}

Expand Down
18 changes: 16 additions & 2 deletions src/coreclr/jit/fgopt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,9 +317,23 @@ PhaseStatus Compiler::fgPostImportationCleanup()
{
LclVarDsc* returnSpillVarDsc = lvaGetDesc(lvaInlineeReturnSpillTemp);

if ((returnSpillVarDsc->lvType == TYP_REF) && returnSpillVarDsc->lvSingleDef)
if ((returnSpillVarDsc->lvType == TYP_REF))
{
lvaUpdateClass(lvaInlineeReturnSpillTemp, retExprClassHnd, impInlineInfo->retExprClassHndIsExact);
if (returnSpillVarDsc->lvSingleDef)
{
lvaUpdateClass(lvaInlineeReturnSpillTemp, retExprClassHnd,
impInlineInfo->retExprClassHndIsExact);
}
else if (lvaInlineeReturnSpillTempFreshlyCreated)
{
// If the inlinee return spill temp was freshly created in fgFindBasicBlocks, we can update the
// type regardless of whether it is single def or not.
returnSpillVarDsc->lvClassHnd = retExprClassHnd;
returnSpillVarDsc->lvClassIsExact = impInlineInfo->retExprClassHndIsExact;
#if DEBUG
returnSpillVarDsc->lvClassInfoUpdated = true;
#endif
}
hez2010 marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
Expand Down
Loading