Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 7cbdc06

Browse files
committed
single-def ret-expr spills
1 parent 5f05d8e commit 7cbdc06

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

src/jit/flowgraph.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5910,6 +5910,12 @@ void Compiler::fgFindBasicBlocks()
59105910
lvaTable[lvaInlineeReturnSpillTemp].lvSingleDef = 1;
59115911
JITDUMP("Marked return spill temp V%02u as a single def temp\n", lvaInlineeReturnSpillTemp);
59125912
}
5913+
else
5914+
{
5915+
// We may have co-opted an existing temp for the return spill.
5916+
// Make sure it is not marked single-def.
5917+
assert(lvaTable[lvaInlineeReturnSpillTemp].lvSingleDef == 0);
5918+
}
59135919

59145920
CORINFO_CLASS_HANDLE retClassHnd = impInlineInfo->inlineCandidateInfo->methInfo.args.retTypeClass;
59155921
if (retClassHnd != nullptr)

src/jit/importer.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20619,10 +20619,25 @@ class SpillRetExprHelper
2061920619
{
2062020620
GenTree* retExpr = *pRetExpr;
2062120621
assert(retExpr->OperGet() == GT_RET_EXPR);
20622-
JITDUMP("Store return expression %u as a local var.\n", retExpr->gtTreeID);
20623-
unsigned tmp = comp->lvaGrabTemp(true DEBUGARG("spilling ret_expr"));
20622+
const unsigned tmp = comp->lvaGrabTemp(true DEBUGARG("spilling ret_expr"));
20623+
JITDUMP("Storing return expression [%06u] to a local var V%02u.\n", comp->dspTreeID(retExpr), tmp);
2062420624
comp->impAssignTempGen(tmp, retExpr, (unsigned)Compiler::CHECK_SPILL_NONE);
2062520625
*pRetExpr = comp->gtNewLclvNode(tmp, retExpr->TypeGet());
20626+
20627+
if (retExpr->TypeGet() == TYP_REF)
20628+
{
20629+
assert(comp->lvaTable[tmp].lvSingleDef == 0);
20630+
comp->lvaTable[tmp].lvSingleDef = 1;
20631+
JITDUMP("Marked V%02u as a single def temp\n", tmp);
20632+
20633+
bool isExact = false;
20634+
bool isNonNull = false;
20635+
CORINFO_CLASS_HANDLE retClsHnd = comp->gtGetClassHandle(retExpr, &isExact, &isNonNull);
20636+
if (retClsHnd != nullptr)
20637+
{
20638+
comp->lvaSetClass(tmp, retClsHnd, isExact);
20639+
}
20640+
}
2062620641
}
2062720642

2062820643
private:

0 commit comments

Comments
 (0)