Skip to content
Merged
Changes from all commits
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: 15 additions & 12 deletions src/coreclr/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16061,10 +16061,11 @@ bool GenTreeIntConCommon::AddrNeedsReloc(Compiler* comp)
//------------------------------------------------------------------------
// IsFieldAddr: Is "this" a static or class field address?
//
// Recognizes the following three patterns:
// this: [Zero FldSeq]
// this: ADD(baseAddr, CONST FldSeq)
// this: ADD(CONST FldSeq, baseAddr)
// Recognizes the following patterns:
// this: ADD(baseAddr, CONST [FldSeq])
// this: ADD(CONST [FldSeq], baseAddr)
// this: CONST [FldSeq]
// this: Zero [FldSeq]
//
// Arguments:
// comp - the Compiler object
Expand All @@ -16089,7 +16090,7 @@ bool GenTree::IsFieldAddr(Compiler* comp, GenTree** pBaseAddr, FieldSeqNode** pF
*pFldSeq = FieldSeqStore::NotAField();

GenTree* baseAddr = nullptr;
FieldSeqNode* fldSeq = nullptr;
FieldSeqNode* fldSeq = FieldSeqStore::NotAField();

if (OperIs(GT_ADD))
{
Expand All @@ -16113,26 +16114,28 @@ bool GenTree::IsFieldAddr(Compiler* comp, GenTree** pBaseAddr, FieldSeqNode** pF
assert(!baseAddr->TypeIs(TYP_REF) || !comp->GetZeroOffsetFieldMap()->Lookup(baseAddr));
}
}
else if (IsCnsIntOrI() && IsIconHandle(GTF_ICON_STATIC_HDL))
{
assert(!comp->GetZeroOffsetFieldMap()->Lookup(this) && (AsIntCon()->gtFieldSeq != nullptr));
fldSeq = AsIntCon()->gtFieldSeq;
baseAddr = nullptr;
}
else if (comp->GetZeroOffsetFieldMap()->Lookup(this, &fldSeq))
{
baseAddr = this;
}
else
{
// TODO-VNTypes-CQ: recognize the simple GTF_ICON_STATIC_HDL case here. It
// is not recognized right now to preserve previous behavior of this method.
return false;
}

// If we don't have a valid sequence, bail. Note that above we have overloaded an empty
// ("nullptr") sequence as "NotAField", as that's the way it is treated on tree nodes.
if ((fldSeq == nullptr) || (fldSeq == FieldSeqStore::NotAField()) || fldSeq->IsPseudoField())
assert(fldSeq != nullptr);

if ((fldSeq == FieldSeqStore::NotAField()) || fldSeq->IsPseudoField())
{
return false;
}

assert(baseAddr != nullptr);

// The above screens out obviously invalid cases, but we have more checks to perform. The
// sequence returned from this method *must* start with either a class (NOT struct) field
// or a static field. To avoid the expense of calling "getFieldClass" here, we will instead
Expand Down