Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JIT: remove GTF_INX_REFARR_LAYOUT #33098

Merged
merged 6 commits into from
Mar 7, 2020
Merged
Show file tree
Hide file tree
Changes from 5 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
4 changes: 0 additions & 4 deletions src/coreclr/src/jit/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8648,10 +8648,6 @@ void cTreeFlags(Compiler* comp, GenTree* tree)

case GT_INDEX:

if (tree->gtFlags & GTF_INX_REFARR_LAYOUT)
{
chars += printf("[INX_REFARR_LAYOUT]");
}
if (tree->gtFlags & GTF_INX_STRING_LAYOUT)
{
chars += printf("[INX_STRING_LAYOUT]");
Expand Down
12 changes: 0 additions & 12 deletions src/coreclr/src/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9773,18 +9773,6 @@ void Compiler::gtDispNode(GenTree* tree, IndentStack* indentStack, __in __in_z _

case GT_INDEX:
case GT_INDEX_ADDR:

if ((tree->gtFlags & (GTF_IND_VOLATILE | GTF_IND_UNALIGNED)) == 0) // We prefer printing V or U over R
{
if (tree->gtFlags & GTF_INX_REFARR_LAYOUT)
{
printf("R");
--msgLength;
break;
} // R means RefArray
}
__fallthrough;

case GT_FIELD:
case GT_CLS_VAR:
if (tree->gtFlags & GTF_IND_VOLATILE)
Expand Down
6 changes: 0 additions & 6 deletions src/coreclr/src/jit/gentree.h
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,6 @@ struct GenTree
#define GTF_FLD_INITCLASS 0x20000000 // GT_FIELD/GT_CLS_VAR -- field access requires preceding class/static init helper

#define GTF_INX_RNGCHK 0x80000000 // GT_INDEX/GT_INDEX_ADDR -- the array reference should be range-checked.
#define GTF_INX_REFARR_LAYOUT 0x20000000 // GT_INDEX -- TODO: Delete, no longer necessary (https://github.com/dotnet/runtime/issues/32647)
#define GTF_INX_STRING_LAYOUT 0x40000000 // GT_INDEX -- this uses the special string array layout

#define GTF_IND_TGT_NOT_HEAP 0x80000000 // GT_IND -- the target is not on the heap
Expand Down Expand Up @@ -4632,11 +4631,6 @@ struct GenTreeIndex : public GenTreeOp
gtFlags |= GTF_INX_RNGCHK;
}

if (type == TYP_REF)
{
gtFlags |= GTF_INX_REFARR_LAYOUT;
}

gtFlags |= GTF_EXCEPT | GTF_GLOB_REF;
}
#if DEBUGGABLE_GENTREE
Expand Down
13 changes: 5 additions & 8 deletions src/coreclr/src/jit/importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9098,14 +9098,11 @@ GenTree* Compiler::impFixupStructReturnType(GenTree* op, CORINFO_CLASS_HANDLE re
{
GenTree* op1 = op->AsObj()->Addr();

// We will fold away OBJ/ADDR
// except for OBJ/ADDR/INDEX
// as the array type influences the array element's offset
// Later in this method we change op->gtType to info.compRetNativeType
// This is not correct when op is a GT_INDEX as the starting offset
// for the array elements 'elemOffs' is different for an array of
// TYP_REF than an array of TYP_STRUCT (which simply wraps a TYP_REF)
// Also refer to the GTF_INX_REFARR_LAYOUT flag
// We will fold away OBJ/ADDR, except for OBJ/ADDR/INDEX
//
// In the latter case the OBJ type may have a different type
// than the array element type, and we need to preserve the
// array element type for now.
//
if ((op1->gtOper == GT_ADDR) && (op1->AsOp()->gtOp1->gtOper != GT_INDEX))
{
Expand Down
18 changes: 16 additions & 2 deletions src/coreclr/src/jit/morph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5552,8 +5552,15 @@ GenTree* Compiler::fgMorphArrayIndex(GenTree* tree)
// This is an array index expression.
tree->gtFlags |= GTF_IND_ARR_INDEX;

/* An indirection will cause a GPF if the address is null */
tree->gtFlags |= GTF_EXCEPT;
// If there's a bounds check, the the indir won't fault.
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
// If there's a bounds check, the the indir won't fault.
// If there's a bounds check, then the indir won't fault.

if (bndsChk)
{
tree->gtFlags |= GTF_IND_NONFAULTING;
}
else
{
tree->gtFlags |= GTF_EXCEPT;
}

if (nCSE)
{
Expand Down Expand Up @@ -17212,6 +17219,13 @@ void Compiler::fgAddFieldSeqForZeroOffset(GenTree* addr, FieldSeqNode* fieldSeqZ
// We expect 'addr' to be an address at this point.
assert(addr->TypeGet() == TYP_BYREF || addr->TypeGet() == TYP_I_IMPL || addr->TypeGet() == TYP_REF);

// Tunnel through any commas.
const bool commaOnly = true;
addr = addr->gtEffectiveVal(commaOnly);

// We still expect 'addr' to be an address at this point.
assert(addr->TypeGet() == TYP_BYREF || addr->TypeGet() == TYP_I_IMPL || addr->TypeGet() == TYP_REF);

FieldSeqNode* fieldSeqUpdate = fieldSeqZero;
GenTree* fieldSeqNode = addr;
bool fieldSeqRecorded = false;
Expand Down
10 changes: 3 additions & 7 deletions src/coreclr/src/jit/optcse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2696,7 +2696,9 @@ class CSE_Heuristic
GenTree* cse = nullptr;
bool isDef;
FieldSeqNode* fldSeq = nullptr;
bool hasZeroMapAnnotation = m_pCompiler->GetZeroOffsetFieldMap()->Lookup(exp, &fldSeq);
bool commaOnly = true;
GenTree* effectiveExp = exp->gtEffectiveVal(commaOnly);
const bool hasZeroMapAnnotation = m_pCompiler->GetZeroOffsetFieldMap()->Lookup(effectiveExp, &fldSeq);
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like you deleted the place below that uses this bool, is that intentional?


if (IS_CSE_USE(exp->gtCSEnum))
{
Expand Down Expand Up @@ -2907,12 +2909,6 @@ class CSE_Heuristic
// Assign the ssa num for the ref use. Note it may be the reserved num.
ref->AsLclVarCommon()->SetSsaNum(cseSsaNum);

// If it has a zero-offset field seq, copy annotation to the ref
if (hasZeroMapAnnotation)
{
m_pCompiler->fgAddFieldSeqForZeroOffset(ref, fldSeq);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Deleting this?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, originally there were two places the zero map annotation got added -- in the def case, and below the join of the use/def. So it was possible to try and add the zero map annotation to the def twice.

Now we just rely on the common one below the join.


/* Create a comma node for the CSE assignment */
cse = m_pCompiler->gtNewOperNode(GT_COMMA, expTyp, origAsg, ref);
cse->gtVNPair = ref->gtVNPair; // The comma's value is the same as 'val'
Expand Down