Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit f011e5a

Browse files
Fix IMGREL32 static field addr value-num blindspot
When `fgMorphField` lowers a static field reference for which `eeGetRelocTypeHint` returns `IMAGE_REL_BASED_REL32`, it creates an `IntCon`, flagged with `GFT_ICON_STATIC_HDL` and marked with the static field in its `gtFieldSeq` field, to represent the field's address (as opposed to the normal case where it generates a `ClsVar`). This change updates the `IsFieldAddr` helper used by value-numbering/loop-hoisting to recognize such constants as the appropriate field address, which then allows the disambiguation/tracking of accesses to these fields to kick in as it does for `ClsVar` nodes.
1 parent ecf7775 commit f011e5a

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

src/jit/gentree.cpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15215,19 +15215,20 @@ bool GenTree::IsFieldAddr(Compiler* comp, GenTreePtr* pObj, GenTreePtr* pStatic,
1521515215
baseAddr = gtOp.gtOp1;
1521615216
}
1521715217
}
15218+
// Check if "this" has a zero-offset annotation.
15219+
else if (comp->GetZeroOffsetFieldMap()->Lookup(this, &newFldSeq))
15220+
{
15221+
baseAddr = this;
15222+
mustBeStatic = true;
15223+
}
15224+
else if (OperGet() == GT_CNS_INT && gtIntCon.gtFieldSeq != nullptr)
15225+
{
15226+
newFldSeq = gtIntCon.gtFieldSeq;
15227+
}
1521815228
else
1521915229
{
15220-
// Check if "this" has a zero-offset annotation.
15221-
if (!comp->GetZeroOffsetFieldMap()->Lookup(this, &newFldSeq))
15222-
{
15223-
// If not, this is not a field address.
15224-
return false;
15225-
}
15226-
else
15227-
{
15228-
baseAddr = this;
15229-
mustBeStatic = true;
15230-
}
15230+
// This is not a field address.
15231+
return false;
1523115232
}
1523215233

1523315234
// If not we don't have a field seq, it's not a field address.

0 commit comments

Comments
 (0)