Skip to content
Merged
Changes from 1 commit
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
27 changes: 26 additions & 1 deletion src/coreclr/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19887,14 +19887,39 @@ void GenTreeArrAddr::ParseArrayAddress(Compiler* comp, GenTree** pArr, ValueNum*
ValueNum vn = comp->GetValueNumStore()->VNLiberalNormalValue(tree->gtVNPair);
VNFuncApp vnf;

bool treeIsArrayRef = false;

if (tree->TypeIs(TYP_REF) || comp->GetValueNumStore()->IsVNNewArr(vn, &vnf))
{
// This must be the array pointer.
assert(*pArr == nullptr);
*pArr = tree;
assert(inputMul == 1); // Can't multiply the array pointer by anything.
treeIsArrayRef = true;
}
else
else if (tree->OperIs(GT_LCL_VAR) && tree->TypeIs(TYP_BYREF, TYP_I_IMPL))
{
// This is sort of like gtGetClassHandle, but that requires TYP_REF
//
const unsigned lclNum = tree->AsLclVar()->GetLclNum();
CORINFO_CLASS_HANDLE hnd = comp->lvaTable[lclNum].lvClassHnd;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const unsigned lclNum = tree->AsLclVar()->GetLclNum();
CORINFO_CLASS_HANDLE hnd = comp->lvaTable[lclNum].lvClassHnd;
CORINFO_CLASS_HANDLE hnd = comp->lvaGetDesc(tree->AsLclVar())->lvClassHnd;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(mostly just want to see lvaGetDesc instead of raw access into lvaTable)


if (hnd != NO_CLASS_HANDLE)
{
DWORD attribs = comp->info.compCompHnd->getClassAttribs(hnd);
treeIsArrayRef = (attribs & CORINFO_FLG_ARRAY) != 0;

if (treeIsArrayRef)
{
// This must be the array pointer.
assert(*pArr == nullptr);
*pArr = tree;
assert(inputMul == 1); // Can't multiply the array pointer by anything.
}
}
}

if (!treeIsArrayRef)
{
switch (tree->OperGet())
{
Expand Down
Loading