Skip to content

Commit b3465af

Browse files
Handle direct addresses for statics in IsFieldAddr (#64846)
* DEBUG-ONLY: FieldInfo Allows this change to be tested via SPMI. * Handle direct addresses in IsFieldAddr * Always use NotAField in IsFieldAddr No diffs. * Revert "DEBUG-ONLY: FieldInfo" This reverts commit b17817e0354a63319256a0fa0d21b74c2cfbf781.
1 parent 9212310 commit b3465af

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

src/coreclr/jit/gentree.cpp

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16061,10 +16061,11 @@ bool GenTreeIntConCommon::AddrNeedsReloc(Compiler* comp)
1606116061
//------------------------------------------------------------------------
1606216062
// IsFieldAddr: Is "this" a static or class field address?
1606316063
//
16064-
// Recognizes the following three patterns:
16065-
// this: [Zero FldSeq]
16066-
// this: ADD(baseAddr, CONST FldSeq)
16067-
// this: ADD(CONST FldSeq, baseAddr)
16064+
// Recognizes the following patterns:
16065+
// this: ADD(baseAddr, CONST [FldSeq])
16066+
// this: ADD(CONST [FldSeq], baseAddr)
16067+
// this: CONST [FldSeq]
16068+
// this: Zero [FldSeq]
1606816069
//
1606916070
// Arguments:
1607016071
// comp - the Compiler object
@@ -16089,7 +16090,7 @@ bool GenTree::IsFieldAddr(Compiler* comp, GenTree** pBaseAddr, FieldSeqNode** pF
1608916090
*pFldSeq = FieldSeqStore::NotAField();
1609016091

1609116092
GenTree* baseAddr = nullptr;
16092-
FieldSeqNode* fldSeq = nullptr;
16093+
FieldSeqNode* fldSeq = FieldSeqStore::NotAField();
1609316094

1609416095
if (OperIs(GT_ADD))
1609516096
{
@@ -16113,26 +16114,28 @@ bool GenTree::IsFieldAddr(Compiler* comp, GenTree** pBaseAddr, FieldSeqNode** pF
1611316114
assert(!baseAddr->TypeIs(TYP_REF) || !comp->GetZeroOffsetFieldMap()->Lookup(baseAddr));
1611416115
}
1611516116
}
16117+
else if (IsCnsIntOrI() && IsIconHandle(GTF_ICON_STATIC_HDL))
16118+
{
16119+
assert(!comp->GetZeroOffsetFieldMap()->Lookup(this) && (AsIntCon()->gtFieldSeq != nullptr));
16120+
fldSeq = AsIntCon()->gtFieldSeq;
16121+
baseAddr = nullptr;
16122+
}
1611616123
else if (comp->GetZeroOffsetFieldMap()->Lookup(this, &fldSeq))
1611716124
{
1611816125
baseAddr = this;
1611916126
}
1612016127
else
1612116128
{
16122-
// TODO-VNTypes-CQ: recognize the simple GTF_ICON_STATIC_HDL case here. It
16123-
// is not recognized right now to preserve previous behavior of this method.
1612416129
return false;
1612516130
}
1612616131

16127-
// If we don't have a valid sequence, bail. Note that above we have overloaded an empty
16128-
// ("nullptr") sequence as "NotAField", as that's the way it is treated on tree nodes.
16129-
if ((fldSeq == nullptr) || (fldSeq == FieldSeqStore::NotAField()) || fldSeq->IsPseudoField())
16132+
assert(fldSeq != nullptr);
16133+
16134+
if ((fldSeq == FieldSeqStore::NotAField()) || fldSeq->IsPseudoField())
1613016135
{
1613116136
return false;
1613216137
}
1613316138

16134-
assert(baseAddr != nullptr);
16135-
1613616139
// The above screens out obviously invalid cases, but we have more checks to perform. The
1613716140
// sequence returned from this method *must* start with either a class (NOT struct) field
1613816141
// or a static field. To avoid the expense of calling "getFieldClass" here, we will instead

0 commit comments

Comments
 (0)