Skip to content

Commit

Permalink
Support numbering exposed LCL_FLDs
Browse files Browse the repository at this point in the history
  • Loading branch information
SingleAccretion committed Dec 16, 2022
1 parent 801816c commit 225eb65
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions src/coreclr/jit/valuenum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8846,20 +8846,31 @@ void Compiler::fgValueNumberTree(GenTree* tree)
// If this is a (full or partial) def we skip; it will be handled as part of the assignment.
if ((lclFld->gtFlags & GTF_VAR_DEF) == 0)
{
unsigned lclNum = lclFld->GetLclNum();
unsigned lclNum = lclFld->GetLclNum();
LclVarDsc* varDsc = lvaGetDesc(lclNum);

if (!lclFld->HasSsaName())
if (lclFld->HasSsaName())
{
lclFld->gtVNPair.SetBoth(vnStore->VNForExpr(compCurBB, lclFld->TypeGet()));
}
else
{
LclVarDsc* varDsc = lvaGetDesc(lclNum);
ValueNumPair lclVarValue = varDsc->GetPerSsaData(lclFld->GetSsaNum())->m_vnPair;
lclFld->gtVNPair =
vnStore->VNPairForLoad(lclVarValue, lvaLclExactSize(lclNum), lclFld->TypeGet(),
lclFld->GetLclOffs(), lclFld->GetSize());
}
else if (varDsc->IsAddressExposed())
{
// Address-exposed locals are part of ByrefExposed.
ValueNum addrVN = vnStore->VNForFunc(TYP_BYREF, VNF_PtrToLoc, vnStore->VNForIntCon(lclNum),
vnStore->VNForIntPtrCon(lclFld->GetLclOffs()));
ValueNum loadVN = fgValueNumberByrefExposedLoad(lclFld->TypeGet(), addrVN);

lclFld->gtVNPair.SetLiberal(loadVN);
lclFld->gtVNPair.SetConservative(vnStore->VNForExpr(compCurBB, lclFld->TypeGet()));
}
else
{
// An untracked local, and other odd cases.
lclFld->gtVNPair.SetBoth(vnStore->VNForExpr(compCurBB, lclFld->TypeGet()));
}
}
else
{
Expand Down

0 comments on commit 225eb65

Please sign in to comment.