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

Commit

Permalink
single-def ret-expr spills
Browse files Browse the repository at this point in the history
  • Loading branch information
AndyAyersMS committed Dec 3, 2018
1 parent 5f05d8e commit 7cbdc06
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/jit/flowgraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5910,6 +5910,12 @@ void Compiler::fgFindBasicBlocks()
lvaTable[lvaInlineeReturnSpillTemp].lvSingleDef = 1;
JITDUMP("Marked return spill temp V%02u as a single def temp\n", lvaInlineeReturnSpillTemp);
}
else
{
// We may have co-opted an existing temp for the return spill.
// Make sure it is not marked single-def.
assert(lvaTable[lvaInlineeReturnSpillTemp].lvSingleDef == 0);
}

CORINFO_CLASS_HANDLE retClassHnd = impInlineInfo->inlineCandidateInfo->methInfo.args.retTypeClass;
if (retClassHnd != nullptr)
Expand Down
19 changes: 17 additions & 2 deletions src/jit/importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20619,10 +20619,25 @@ class SpillRetExprHelper
{
GenTree* retExpr = *pRetExpr;
assert(retExpr->OperGet() == GT_RET_EXPR);
JITDUMP("Store return expression %u as a local var.\n", retExpr->gtTreeID);
unsigned tmp = comp->lvaGrabTemp(true DEBUGARG("spilling ret_expr"));
const unsigned tmp = comp->lvaGrabTemp(true DEBUGARG("spilling ret_expr"));
JITDUMP("Storing return expression [%06u] to a local var V%02u.\n", comp->dspTreeID(retExpr), tmp);
comp->impAssignTempGen(tmp, retExpr, (unsigned)Compiler::CHECK_SPILL_NONE);
*pRetExpr = comp->gtNewLclvNode(tmp, retExpr->TypeGet());

if (retExpr->TypeGet() == TYP_REF)
{
assert(comp->lvaTable[tmp].lvSingleDef == 0);
comp->lvaTable[tmp].lvSingleDef = 1;
JITDUMP("Marked V%02u as a single def temp\n", tmp);

bool isExact = false;
bool isNonNull = false;
CORINFO_CLASS_HANDLE retClsHnd = comp->gtGetClassHandle(retExpr, &isExact, &isNonNull);
if (retClsHnd != nullptr)
{
comp->lvaSetClass(tmp, retClsHnd, isExact);
}
}
}

private:
Expand Down

0 comments on commit 7cbdc06

Please sign in to comment.