Skip to content

Commit

Permalink
Adjust impNormStructVal to not wrap in GT_OBJ (#81636)
Browse files Browse the repository at this point in the history
* Adjust impNormStructVal to not wrap in GT_OBJ

* Ensure UpdateEarlyRefCount handles CALL(LCL_VAR)
  • Loading branch information
tannergooding committed Feb 6, 2023
1 parent 211cb69 commit 58719ec
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 38 deletions.
11 changes: 0 additions & 11 deletions src/coreclr/jit/importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1332,11 +1332,6 @@ GenTree* Compiler::impNormStructVal(GenTree* structVal, CORINFO_CLASS_HANDLE str

case GT_LCL_VAR:
case GT_LCL_FLD:
structLcl = structVal->AsLclVarCommon();
// Wrap it in a GT_OBJ.
structVal = gtNewObjNode(structHnd, gtNewOperNode(GT_ADDR, TYP_BYREF, structVal));
FALLTHROUGH;

case GT_IND:
case GT_OBJ:
case GT_BLK:
Expand Down Expand Up @@ -1414,12 +1409,6 @@ GenTree* Compiler::impNormStructVal(GenTree* structVal, CORINFO_CLASS_HANDLE str

structLcl = gtNewLclvNode(tmpNum, structType)->AsLclVarCommon();
structVal = structLcl;

if (structType == TYP_STRUCT)
{
// Wrap it in a GT_OBJ
structVal = gtNewObjNode(structHnd, gtNewOperNode(GT_ADDR, TYP_BYREF, structVal));
}
}

if (structLcl != nullptr)
Expand Down
56 changes: 29 additions & 27 deletions src/coreclr/jit/lclmorph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1565,40 +1565,42 @@ class LocalAddressVisitor final : public GenTreeVisitor<LocalAddressVisitor>
// handled in fgCanFastTailCall and fgMakeOutgoingStructArgCopy.
//
// CALL(OBJ(LCL_VAR_ADDR...))
bool isArgToCall = false;
bool keepSearching = true;
for (int i = 0; i < m_ancestors.Height() && keepSearching; i++)
// -or-
// CALL(LCL_VAR)

// TODO-1stClassStructs: We've removed most, but not all, cases where OBJ(LCL_VAR_ADDR)
// is introduced (it was primarily from impNormStructVal). But until all cases are gone
// we still want to handle it as well.

if (m_ancestors.Height() < 2)
{
return;
}

GenTree* node = m_ancestors.Top(0);

if (node->OperIs(GT_LCL_VAR))
{
GenTree* node = m_ancestors.Top(i);
switch (i)
node = m_ancestors.Top(1);
}
else if (node->OperIs(GT_LCL_VAR_ADDR))
{
if (m_ancestors.Height() < 3)
{
case 0:
{
keepSearching = node->OperIs(GT_LCL_VAR_ADDR);
}
break;
return;
}

case 1:
{
keepSearching = node->OperIs(GT_OBJ);
}
break;
node = m_ancestors.Top(1);

case 2:
{
keepSearching = false;
isArgToCall = node->IsCall();
}
break;
default:
{
keepSearching = false;
}
break;
if (!node->OperIs(GT_OBJ))
{
return;
}

node = m_ancestors.Top(2);
}

if (isArgToCall)
if (node->IsCall())
{
JITDUMP("LocalAddressVisitor incrementing weighted ref count from " FMT_WT " to " FMT_WT
" for implicit by-ref V%02d arg passed to call\n",
Expand Down

0 comments on commit 58719ec

Please sign in to comment.