-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Improve LIR dumping #10140
Improve LIR dumping #10140
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12002,16 +12002,22 @@ void Compiler::gtDispTreeRange(LIR::Range& containingRange, GenTree* tree) | |
// | ||
// Arguments: | ||
// node - the LIR node to dump. | ||
// prefixMsg - an optional prefix for each line of output. | ||
// | ||
void Compiler::gtDispLIRNode(GenTree* node) | ||
void Compiler::gtDispLIRNode(GenTree* node, const char* prefixMsg /* = nullptr */) | ||
{ | ||
auto displayOperand = [](GenTree* operand, const char* message, IndentInfo operandArc, IndentStack& indentStack) { | ||
auto displayOperand = [](GenTree* operand, const char* message, IndentInfo operandArc, IndentStack& indentStack, const char* prefixMsg = nullptr) { | ||
assert(operand != nullptr); | ||
assert(message != nullptr); | ||
|
||
if (prefixMsg != nullptr) | ||
{ | ||
printf("%s", prefixMsg); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor nit: you could capture the length of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The issue is that the prefixMsg is output for both the operand (here), and the operator (below), and the operator doesn't have any leading space. And, I want the operator and operands to be indented by the same amount, when a prefixMsg is given. Here's an example from codegen:
A "full dump" looks like:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is hugely picky of me, but is there any chance we could avoid printing the message before the operands? No big deal if there isn't. |
||
} | ||
|
||
// 49 spaces for alignment | ||
printf("%-49s", ""); | ||
#ifdef FEATURE_SET_FLAGS | ||
#if FEATURE_SET_FLAGS | ||
// additional flag enlarges the flag field by one character | ||
printf(" "); | ||
#endif | ||
|
@@ -12022,7 +12028,6 @@ void Compiler::gtDispLIRNode(GenTree* node) | |
operandArc = IIArc; | ||
|
||
printf(" t%-5d %-6s %s\n", operand->gtTreeID, varTypeName(operand->TypeGet()), message); | ||
|
||
}; | ||
|
||
IndentStack indentStack(this); | ||
|
@@ -12048,19 +12053,19 @@ void Compiler::gtDispLIRNode(GenTree* node) | |
if (operand == call->gtCallObjp) | ||
{ | ||
sprintf_s(buf, sizeof(buf), "this in %s", compRegVarName(REG_ARG_0)); | ||
displayOperand(operand, buf, operandArc, indentStack); | ||
displayOperand(operand, buf, operandArc, indentStack, prefixMsg); | ||
} | ||
else if (operand == call->gtCallAddr) | ||
{ | ||
displayOperand(operand, "calli tgt", operandArc, indentStack); | ||
displayOperand(operand, "calli tgt", operandArc, indentStack, prefixMsg); | ||
} | ||
else if (operand == call->gtControlExpr) | ||
{ | ||
displayOperand(operand, "control expr", operandArc, indentStack); | ||
displayOperand(operand, "control expr", operandArc, indentStack, prefixMsg); | ||
} | ||
else if (operand == call->gtCallCookie) | ||
{ | ||
displayOperand(operand, "cookie", operandArc, indentStack); | ||
displayOperand(operand, "cookie", operandArc, indentStack, prefixMsg); | ||
} | ||
else | ||
{ | ||
|
@@ -12082,7 +12087,7 @@ void Compiler::gtDispLIRNode(GenTree* node) | |
gtGetLateArgMsg(call, operand, curArgTabEntry->lateArgInx, listIndex, buf, sizeof(buf)); | ||
} | ||
|
||
displayOperand(operand, buf, operandArc, indentStack); | ||
displayOperand(operand, buf, operandArc, indentStack, prefixMsg); | ||
operandArc = IIArc; | ||
} | ||
} | ||
|
@@ -12097,63 +12102,67 @@ void Compiler::gtDispLIRNode(GenTree* node) | |
gtGetLateArgMsg(call, operand, curArgTabEntry->lateArgInx, -1, buf, sizeof(buf)); | ||
} | ||
|
||
displayOperand(operand, buf, operandArc, indentStack); | ||
displayOperand(operand, buf, operandArc, indentStack, prefixMsg); | ||
} | ||
} | ||
} | ||
else if (node->OperIsDynBlkOp()) | ||
{ | ||
if (operand == node->AsBlk()->Addr()) | ||
{ | ||
displayOperand(operand, "lhs", operandArc, indentStack); | ||
displayOperand(operand, "lhs", operandArc, indentStack, prefixMsg); | ||
} | ||
else if (operand == node->AsBlk()->Data()) | ||
{ | ||
displayOperand(operand, "rhs", operandArc, indentStack); | ||
displayOperand(operand, "rhs", operandArc, indentStack, prefixMsg); | ||
} | ||
else | ||
{ | ||
assert(operand == node->AsDynBlk()->gtDynamicSize); | ||
displayOperand(operand, "size", operandArc, indentStack); | ||
displayOperand(operand, "size", operandArc, indentStack, prefixMsg); | ||
} | ||
} | ||
else if (node->OperGet() == GT_DYN_BLK) | ||
{ | ||
if (operand == node->AsBlk()->Addr()) | ||
{ | ||
displayOperand(operand, "lhs", operandArc, indentStack); | ||
displayOperand(operand, "lhs", operandArc, indentStack, prefixMsg); | ||
} | ||
else | ||
{ | ||
assert(operand == node->AsDynBlk()->gtDynamicSize); | ||
displayOperand(operand, "size", operandArc, indentStack); | ||
displayOperand(operand, "size", operandArc, indentStack, prefixMsg); | ||
} | ||
} | ||
else if (node->OperIsAssignment()) | ||
{ | ||
if (operand == node->gtGetOp1()) | ||
{ | ||
displayOperand(operand, "lhs", operandArc, indentStack); | ||
displayOperand(operand, "lhs", operandArc, indentStack, prefixMsg); | ||
} | ||
else | ||
{ | ||
displayOperand(operand, "rhs", operandArc, indentStack); | ||
displayOperand(operand, "rhs", operandArc, indentStack, prefixMsg); | ||
} | ||
} | ||
else | ||
{ | ||
displayOperand(operand, "", operandArc, indentStack); | ||
displayOperand(operand, "", operandArc, indentStack, prefixMsg); | ||
} | ||
|
||
operandArc = IIArc; | ||
} | ||
|
||
// Visit the operator | ||
|
||
if (prefixMsg != nullptr) | ||
{ | ||
printf("%s", prefixMsg); | ||
} | ||
|
||
const bool topOnly = true; | ||
const bool isLIR = true; | ||
gtDispTree(node, &indentStack, nullptr, topOnly, isLIR); | ||
|
||
printf("\n"); | ||
} | ||
|
||
/*****************************************************************************/ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you not set a breakpoint on
treeNode->gtSeqNum
itself?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like it. I just copy-and-pasted that from the other codegen files. Since it doesn't hurt, it made sense to keep it the same.