Skip to content

Commit 34aa89e

Browse files
authored
Merge pull request dotnet#23876 from briansull/jit-dump
Improved JitDump
2 parents 37ab0d5 + 3cd62e2 commit 34aa89e

File tree

3 files changed

+86
-48
lines changed

3 files changed

+86
-48
lines changed

src/jit/compiler.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2864,11 +2864,13 @@ class Compiler
28642864
#ifdef DEBUG
28652865
void gtDispNode(GenTree* tree, IndentStack* indentStack, __in_z const char* msg, bool isLIR);
28662866

2867-
void gtDispVN(GenTree* tree);
28682867
void gtDispConst(GenTree* tree);
28692868
void gtDispLeaf(GenTree* tree, IndentStack* indentStack);
28702869
void gtDispNodeName(GenTree* tree);
28712870
void gtDispRegVal(GenTree* tree);
2871+
void gtDispZeroFieldSeq(GenTree* tree);
2872+
void gtDispVN(GenTree* tree);
2873+
void gtDispCommonEndLine(GenTree* tree);
28722874

28732875
enum IndentInfo
28742876
{

src/jit/flowgraph.cpp

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20066,6 +20066,18 @@ void Compiler::fgTableDispBasicBlock(BasicBlock* block, int ibcColWidth /* = 0 *
2006620066

2006720067
printf(" ");
2006820068

20069+
//
20070+
// Display natural loop number
20071+
//
20072+
if (block->bbNatLoopNum == BasicBlock::NOT_IN_LOOP)
20073+
{
20074+
printf(" ");
20075+
}
20076+
else
20077+
{
20078+
printf("%2d ", block->bbNatLoopNum);
20079+
}
20080+
2006920081
//
2007020082
// Display block IL range
2007120083
//
@@ -20326,11 +20338,11 @@ void Compiler::fgDispBasicBlocks(BasicBlock* firstBlock, BasicBlock* lastBlock,
2032620338
// clang-format off
2032720339

2032820340
printf("\n");
20329-
printf("------%*s-------------------------------------%*s-----------------------%*s----------------------------------------\n",
20341+
printf("------%*s-------------------------------------%*s--------------------------%*s----------------------------------------\n",
2033020342
padWidth, "------------",
2033120343
ibcColWidth, "------------",
2033220344
maxBlockNumWidth, "----");
20333-
printf("BBnum %*sBBid ref try hnd %s weight %*s%s [IL range] [jump]%*s [EH region] [flags]\n",
20345+
printf("BBnum %*sBBid ref try hnd %s weight %*s%s lp [IL range] [jump]%*s [EH region] [flags]\n",
2033420346
padWidth, "",
2033520347
fgCheapPredsValid ? "cheap preds" :
2033620348
(fgComputePredsDone ? "preds "
@@ -20340,7 +20352,7 @@ void Compiler::fgDispBasicBlocks(BasicBlock* firstBlock, BasicBlock* lastBlock,
2034020352
: ""),
2034120353
maxBlockNumWidth, ""
2034220354
);
20343-
printf("------%*s-------------------------------------%*s-----------------------%*s----------------------------------------\n",
20355+
printf("------%*s-------------------------------------%*s--------------------------%*s----------------------------------------\n",
2034420356
padWidth, "------------",
2034520357
ibcColWidth, "------------",
2034620358
maxBlockNumWidth, "----");
@@ -20364,17 +20376,19 @@ void Compiler::fgDispBasicBlocks(BasicBlock* firstBlock, BasicBlock* lastBlock,
2036420376

2036520377
if (block == fgFirstColdBlock)
2036620378
{
20367-
printf("~~~~~~%*s~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%*s~~~~~~~~~~~~~~~~~~~~~~~%*s~~~~~~~~~~~~~~~~~~~~~~~~"
20368-
"~~~~~~~~~~~~~~~~\n",
20369-
padWidth, "~~~~~~~~~~~~", ibcColWidth, "~~~~~~~~~~~~", maxBlockNumWidth, "~~~~");
20379+
printf(
20380+
"~~~~~~%*s~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%*s~~~~~~~~~~~~~~~~~~~~~~~~~~%*s~~~~~~~~~~~~~~~~~~~~~~~~"
20381+
"~~~~~~~~~~~~~~~~\n",
20382+
padWidth, "~~~~~~~~~~~~", ibcColWidth, "~~~~~~~~~~~~", maxBlockNumWidth, "~~~~");
2037020383
}
2037120384

2037220385
#if FEATURE_EH_FUNCLETS
2037320386
if (block == fgFirstFuncletBB)
2037420387
{
20375-
printf("++++++%*s+++++++++++++++++++++++++++++++++++++%*s+++++++++++++++++++++++%*s++++++++++++++++++++++++"
20376-
"++++++++++++++++ funclets follow\n",
20377-
padWidth, "++++++++++++", ibcColWidth, "++++++++++++", maxBlockNumWidth, "++++");
20388+
printf(
20389+
"++++++%*s+++++++++++++++++++++++++++++++++++++%*s++++++++++++++++++++++++++%*s++++++++++++++++++++++++"
20390+
"++++++++++++++++ funclets follow\n",
20391+
padWidth, "++++++++++++", ibcColWidth, "++++++++++++", maxBlockNumWidth, "++++");
2037820392
}
2037920393
#endif // FEATURE_EH_FUNCLETS
2038020394

@@ -20386,9 +20400,10 @@ void Compiler::fgDispBasicBlocks(BasicBlock* firstBlock, BasicBlock* lastBlock,
2038620400
}
2038720401
}
2038820402

20389-
printf("------%*s-------------------------------------%*s-----------------------%*s--------------------------------"
20390-
"--------\n",
20391-
padWidth, "------------", ibcColWidth, "------------", maxBlockNumWidth, "----");
20403+
printf(
20404+
"------%*s-------------------------------------%*s--------------------------%*s--------------------------------"
20405+
"--------\n",
20406+
padWidth, "------------", ibcColWidth, "------------", maxBlockNumWidth, "----");
2039220407

2039320408
if (dumpTrees)
2039420409
{

src/jit/gentree.cpp

Lines changed: 56 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -9220,6 +9220,29 @@ void Compiler::gtDispNodeName(GenTree* tree)
92209220
}
92219221
}
92229222

9223+
//------------------------------------------------------------------------
9224+
// gtDispZeroFieldSeq: If this node has a zero fieldSeq annotation
9225+
// then print this Field Sequence
9226+
//
9227+
void Compiler::gtDispZeroFieldSeq(GenTree* tree)
9228+
{
9229+
NodeToFieldSeqMap* map = GetZeroOffsetFieldMap();
9230+
9231+
// THe most common case is having no entries in this map
9232+
if (map->GetCount() > 0)
9233+
{
9234+
FieldSeqNode* fldSeq = nullptr;
9235+
if (map->Lookup(tree, &fldSeq))
9236+
{
9237+
printf(" Zero");
9238+
gtDispFieldSeq(fldSeq);
9239+
}
9240+
}
9241+
}
9242+
9243+
//------------------------------------------------------------------------
9244+
// gtDispVN: Utility function that prints a tree's ValueNumber: gtVNPair
9245+
//
92239246
void Compiler::gtDispVN(GenTree* tree)
92249247
{
92259248
if (tree->gtVNPair.GetLiberal() != ValueNumStore::NoVN)
@@ -9230,6 +9253,22 @@ void Compiler::gtDispVN(GenTree* tree)
92309253
}
92319254
}
92329255

9256+
//------------------------------------------------------------------------
9257+
// gtDispCommonEndLine
9258+
// Utility function that prints the following node information
9259+
// 1: The associated zero field sequence (if any)
9260+
// 2. The register assigned to this node (if any)
9261+
// 2. The value number assigned (if any)
9262+
// 3. A newline character
9263+
//
9264+
void Compiler::gtDispCommonEndLine(GenTree* tree)
9265+
{
9266+
gtDispZeroFieldSeq(tree);
9267+
gtDispRegVal(tree);
9268+
gtDispVN(tree);
9269+
printf("\n");
9270+
}
9271+
92339272
//------------------------------------------------------------------------
92349273
// gtDispNode: Print a tree to jitstdout.
92359274
//
@@ -10189,8 +10228,6 @@ void Compiler::gtDispConst(GenTree* tree)
1018910228
default:
1019010229
assert(!"unexpected constant node");
1019110230
}
10192-
10193-
gtDispRegVal(tree);
1019410231
}
1019510232

1019610233
void Compiler::gtDispFieldSeq(FieldSeqNode* pfsn)
@@ -10442,8 +10479,6 @@ void Compiler::gtDispLeaf(GenTree* tree, IndentStack* indentStack)
1044210479
default:
1044310480
assert(!"don't know how to display tree leaf node");
1044410481
}
10445-
10446-
gtDispRegVal(tree);
1044710482
}
1044810483

1044910484
//------------------------------------------------------------------------
@@ -10523,8 +10558,8 @@ void Compiler::gtDispTree(GenTree* tree,
1052310558
{
1052410559
gtDispNode(tree, indentStack, msg, isLIR);
1052510560
gtDispLeaf(tree, indentStack);
10526-
gtDispVN(tree);
10527-
printf("\n");
10561+
gtDispCommonEndLine(tree);
10562+
1052810563
if (tree->OperIsLocalStore() && !topOnly)
1052910564
{
1053010565
gtDispChild(tree->gtOp.gtOp1, indentStack, IINone);
@@ -10571,8 +10606,7 @@ void Compiler::gtDispTree(GenTree* tree,
1057110606
if (tree->OperGet() == GT_PHI)
1057210607
{
1057310608
gtDispNode(tree, indentStack, msg, isLIR);
10574-
gtDispVN(tree);
10575-
printf("\n");
10609+
gtDispCommonEndLine(tree);
1057610610

1057710611
if (!topOnly)
1057810612
{
@@ -10813,9 +10847,7 @@ void Compiler::gtDispTree(GenTree* tree,
1081310847
}
1081410848
#endif // FEATURE_HW_INTRINSICS
1081510849

10816-
gtDispRegVal(tree);
10817-
gtDispVN(tree);
10818-
printf("\n");
10850+
gtDispCommonEndLine(tree);
1081910851

1082010852
if (!topOnly && tree->gtOp.gtOp1)
1082110853
{
@@ -10866,18 +10898,13 @@ void Compiler::gtDispTree(GenTree* tree,
1086610898
printf(" %s", eeGetFieldName(tree->gtField.gtFldHnd), 0);
1086710899
}
1086810900

10901+
gtDispCommonEndLine(tree);
10902+
1086910903
if (tree->gtField.gtFldObj && !topOnly)
1087010904
{
10871-
gtDispVN(tree);
10872-
printf("\n");
1087310905
gtDispChild(tree->gtField.gtFldObj, indentStack, IIArcBottom);
1087410906
}
10875-
else
10876-
{
10877-
gtDispRegVal(tree);
10878-
gtDispVN(tree);
10879-
printf("\n");
10880-
}
10907+
1088110908
break;
1088210909

1088310910
case GT_CALL:
@@ -10912,12 +10939,7 @@ void Compiler::gtDispTree(GenTree* tree,
1091210939
printf(" (exactContextHnd=0x%p)", dspPtr(call->gtInlineCandidateInfo->exactContextHnd));
1091310940
}
1091410941

10915-
gtDispVN(call);
10916-
if (call->IsMultiRegCall())
10917-
{
10918-
gtDispRegVal(call);
10919-
}
10920-
printf("\n");
10942+
gtDispCommonEndLine(tree);
1092110943

1092210944
if (!topOnly)
1092310945
{
@@ -10988,8 +11010,7 @@ void Compiler::gtDispTree(GenTree* tree,
1098811010
break;
1098911011

1099011012
case GT_ARR_ELEM:
10991-
gtDispVN(tree);
10992-
printf("\n");
11013+
gtDispCommonEndLine(tree);
1099311014

1099411015
if (!topOnly)
1099511016
{
@@ -11005,8 +11026,8 @@ void Compiler::gtDispTree(GenTree* tree,
1100511026
break;
1100611027

1100711028
case GT_ARR_OFFSET:
11008-
gtDispVN(tree);
11009-
printf("\n");
11029+
gtDispCommonEndLine(tree);
11030+
1101011031
if (!topOnly)
1101111032
{
1101211033
gtDispChild(tree->gtArrOffs.gtOffset, indentStack, IIArc, nullptr, topOnly);
@@ -11016,8 +11037,8 @@ void Compiler::gtDispTree(GenTree* tree,
1101611037
break;
1101711038

1101811039
case GT_CMPXCHG:
11019-
gtDispVN(tree);
11020-
printf("\n");
11040+
gtDispCommonEndLine(tree);
11041+
1102111042
if (!topOnly)
1102211043
{
1102311044
gtDispChild(tree->gtCmpXchg.gtOpLocation, indentStack, IIArc, nullptr, topOnly);
@@ -11033,8 +11054,8 @@ void Compiler::gtDispTree(GenTree* tree,
1103311054
#ifdef FEATURE_HW_INTRINSICS
1103411055
case GT_HW_INTRINSIC_CHK:
1103511056
#endif // FEATURE_HW_INTRINSICS
11036-
gtDispVN(tree);
11037-
printf("\n");
11057+
gtDispCommonEndLine(tree);
11058+
1103811059
if (!topOnly)
1103911060
{
1104011061
gtDispChild(tree->gtBoundsChk.gtIndex, indentStack, IIArc, nullptr, topOnly);
@@ -11052,8 +11073,8 @@ void Compiler::gtDispTree(GenTree* tree,
1105211073
{
1105311074
printf(" (init)");
1105411075
}
11055-
gtDispVN(tree);
11056-
printf("\n");
11076+
gtDispCommonEndLine(tree);
11077+
1105711078
if (!topOnly)
1105811079
{
1105911080
if (tree->gtDynBlk.Data() != nullptr)

0 commit comments

Comments
 (0)