Skip to content

Commit 7ce21ab

Browse files
NotAField printing improvements
1 parent bbcedae commit 7ce21ab

File tree

4 files changed

+43
-15
lines changed

4 files changed

+43
-15
lines changed

src/coreclr/jit/compiler.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3625,6 +3625,7 @@ class Compiler
36253625
void gtGetArgMsg(GenTreeCall* call, GenTree* arg, unsigned argNum, char* bufp, unsigned bufLength);
36263626
void gtGetLateArgMsg(GenTreeCall* call, GenTree* arg, int argNum, char* bufp, unsigned bufLength);
36273627
void gtDispArgList(GenTreeCall* call, GenTree* lastCallOperand, IndentStack* indentStack);
3628+
void gtDispAnyFieldSeq(FieldSeqNode* fieldSeq);
36283629
void gtDispFieldSeq(FieldSeqNode* pfsn);
36293630

36303631
void gtDispRange(LIR::ReadOnlyRange const& range);

src/coreclr/jit/gentree.cpp

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9178,7 +9178,7 @@ void Compiler::gtDispZeroFieldSeq(GenTree* tree)
91789178
if (map->Lookup(tree, &fldSeq))
91799179
{
91809180
printf(" Zero");
9181-
gtDispFieldSeq(fldSeq);
9181+
gtDispAnyFieldSeq(fldSeq);
91829182
}
91839183
}
91849184
}
@@ -10295,9 +10295,28 @@ void Compiler::gtDispConst(GenTree* tree)
1029510295
}
1029610296
}
1029710297

10298+
//------------------------------------------------------------------------
10299+
// gtDispFieldSeq: "gtDispFieldSeq" that also prints "<NotAField>".
10300+
//
10301+
// Useful for printing zero-offset field sequences.
10302+
//
10303+
void Compiler::gtDispAnyFieldSeq(FieldSeqNode* fieldSeq)
10304+
{
10305+
if (fieldSeq == FieldSeqStore::NotAField())
10306+
{
10307+
printf(" Fseq<NotAField>");
10308+
return;
10309+
}
10310+
10311+
gtDispFieldSeq(fieldSeq);
10312+
}
10313+
10314+
//------------------------------------------------------------------------
10315+
// gtDispFieldSeq: Print out the fields in this field sequence.
10316+
//
1029810317
void Compiler::gtDispFieldSeq(FieldSeqNode* pfsn)
1029910318
{
10300-
if (pfsn == FieldSeqStore::NotAField() || (pfsn == nullptr))
10319+
if ((pfsn == nullptr) || (pfsn == FieldSeqStore::NotAField()))
1030110320
{
1030210321
return;
1030310322
}

src/coreclr/jit/morph.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17844,7 +17844,7 @@ void Compiler::fgAddFieldSeqForZeroOffset(GenTree* addr, FieldSeqNode* fieldSeqZ
1784417844
if (verbose)
1784517845
{
1784617846
printf("\nfgAddFieldSeqForZeroOffset for");
17847-
gtDispFieldSeq(fieldSeqZero);
17847+
gtDispAnyFieldSeq(fieldSeqZero);
1784817848

1784917849
printf("\naddr (Before)\n");
1785017850
gtDispNode(addr, nullptr, nullptr, false);

src/coreclr/jit/valuenum.cpp

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4167,32 +4167,33 @@ ValueNum ValueNumStore::VNForFieldSeq(FieldSeqNode* fieldSeq)
41674167
{
41684168
return VNForNull();
41694169
}
4170-
else if (fieldSeq == FieldSeqStore::NotAField())
4170+
4171+
ValueNum fieldSeqVN;
4172+
if (fieldSeq == FieldSeqStore::NotAField())
41714173
{
41724174
// We always allocate a new, unique VN in this call.
41734175
Chunk* c = GetAllocChunk(TYP_REF, CEA_NotAField);
41744176
unsigned offsetWithinChunk = c->AllocVN();
4175-
ValueNum result = c->m_baseVN + offsetWithinChunk;
4176-
return result;
4177+
fieldSeqVN = c->m_baseVN + offsetWithinChunk;
41774178
}
41784179
else
41794180
{
41804181
ssize_t fieldHndVal = ssize_t(fieldSeq->m_fieldHnd);
41814182
ValueNum fieldHndVN = VNForHandle(fieldHndVal, GTF_ICON_FIELD_HDL);
41824183
ValueNum seqNextVN = VNForFieldSeq(fieldSeq->m_next);
4183-
ValueNum fieldSeqVN = VNForFunc(TYP_REF, VNF_FieldSeq, fieldHndVN, seqNextVN);
4184+
fieldSeqVN = VNForFunc(TYP_REF, VNF_FieldSeq, fieldHndVN, seqNextVN);
4185+
}
41844186

41854187
#ifdef DEBUG
4186-
if (m_pComp->verbose)
4187-
{
4188-
printf(" FieldSeq");
4189-
vnDump(m_pComp, fieldSeqVN);
4190-
printf(" is " FMT_VN "\n", fieldSeqVN);
4191-
}
4188+
if (m_pComp->verbose)
4189+
{
4190+
printf(" FieldSeq");
4191+
vnDump(m_pComp, fieldSeqVN);
4192+
printf(" is " FMT_VN "\n", fieldSeqVN);
4193+
}
41924194
#endif
41934195

4194-
return fieldSeqVN;
4195-
}
4196+
return fieldSeqVN;
41964197
}
41974198

41984199
FieldSeqNode* ValueNumStore::FieldSeqVNToFieldSeq(ValueNum vn)
@@ -5961,6 +5962,7 @@ void ValueNumStore::vnDump(Compiler* comp, ValueNum vn, bool isPtr)
59615962
switch (funcApp.m_func)
59625963
{
59635964
case VNF_FieldSeq:
5965+
case VNF_NotAField:
59645966
vnDumpFieldSeq(comp, &funcApp, true);
59655967
break;
59665968
case VNF_MapSelect:
@@ -6068,6 +6070,12 @@ void ValueNumStore::vnDumpExcSeq(Compiler* comp, VNFuncApp* excSeq, bool isHead)
60686070

60696071
void ValueNumStore::vnDumpFieldSeq(Compiler* comp, VNFuncApp* fieldSeq, bool isHead)
60706072
{
6073+
if (fieldSeq->m_func == VNF_NotAField)
6074+
{
6075+
printf("<NotAField>");
6076+
return;
6077+
}
6078+
60716079
assert(fieldSeq->m_func == VNF_FieldSeq); // Precondition.
60726080
// First arg is the field handle VN.
60736081
assert(IsVNConstant(fieldSeq->m_args[0]) && TypeOfVN(fieldSeq->m_args[0]) == TYP_I_IMPL);

0 commit comments

Comments
 (0)