diff --git a/src/jit/codegenarm.cpp b/src/jit/codegenarm.cpp index e9f8ff295fa4..97d73cb864cf 100644 --- a/src/jit/codegenarm.cpp +++ b/src/jit/codegenarm.cpp @@ -501,11 +501,13 @@ void CodeGen::genCodeForTreeNode(GenTreePtr treeNode) #ifdef DEBUG lastConsumedNode = nullptr; + if (compiler->verbose) + { + unsigned seqNum = treeNode->gtSeqNum; // Useful for setting a conditional break in Visual Studio + compiler->gtDispLIRNode(treeNode, "Generating: "); + } #endif - JITDUMP("Generating: "); - DISPNODE(treeNode); - // contained nodes are part of their parents for codegen purposes // ex : immediates, most LEAs if (treeNode->isContained()) diff --git a/src/jit/codegenarm64.cpp b/src/jit/codegenarm64.cpp index 62ebc48d772c..09e56d79a1fe 100644 --- a/src/jit/codegenarm64.cpp +++ b/src/jit/codegenarm64.cpp @@ -1923,8 +1923,7 @@ void CodeGen::genCodeForTreeNode(GenTreePtr treeNode) if (compiler->verbose) { unsigned seqNum = treeNode->gtSeqNum; // Useful for setting a conditional break in Visual Studio - printf("Generating: "); - compiler->gtDispTree(treeNode, nullptr, nullptr, true); + compiler->gtDispLIRNode(treeNode, "Generating: "); } #endif // DEBUG diff --git a/src/jit/codegenxarch.cpp b/src/jit/codegenxarch.cpp index 6acbe58508b5..7938ca074df0 100644 --- a/src/jit/codegenxarch.cpp +++ b/src/jit/codegenxarch.cpp @@ -1266,8 +1266,7 @@ void CodeGen::genCodeForTreeNode(GenTreePtr treeNode) if (compiler->verbose) { unsigned seqNum = treeNode->gtSeqNum; // Useful for setting a conditional break in Visual Studio - printf("Generating: "); - compiler->gtDispTree(treeNode, nullptr, nullptr, true); + compiler->gtDispLIRNode(treeNode, "Generating: "); } #endif // DEBUG diff --git a/src/jit/compiler.cpp b/src/jit/compiler.cpp index 423a0447150a..cfb17f41f33f 100644 --- a/src/jit/compiler.cpp +++ b/src/jit/compiler.cpp @@ -8164,11 +8164,12 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX * The versions that start with 'd' use the tlsCompiler, so don't require a Compiler*. * * Summary: - * cBlock, dBlock : Display a basic block (call fgDispBasicBlock()). + * cBlock, dBlock : Display a basic block (call fgTableDispBasicBlock()). * cBlocks, dBlocks : Display all the basic blocks of a function (call fgDispBasicBlocks()). * cBlocksV, dBlocksV : Display all the basic blocks of a function (call fgDispBasicBlocks(true)). * "V" means "verbose", and will dump all the trees. * cTree, dTree : Display a tree (call gtDispTree()). + * cTreeLIR, dTreeLIR : Display a tree in LIR form (call gtDispLIRNode()). * cTrees, dTrees : Display all the trees in a function (call fgDumpTrees()). * cEH, dEH : Display the EH handler table (call fgDispHandlerTab()). * cVar, dVar : Display a local variable given its number (call lvaDumpEntry()). @@ -8238,6 +8239,13 @@ void cTree(Compiler* comp, GenTree* tree) comp->gtDispTree(tree, nullptr, ">>>"); } +void cTreeLIR(Compiler* comp, GenTree* tree) +{ + static unsigned sequenceNumber = 0; // separate calls with a number to indicate this function has been called + printf("===================================================================== *TreeLIR %u\n", sequenceNumber++); + comp->gtDispLIRNode(tree); +} + void cTrees(Compiler* comp) { static unsigned sequenceNumber = 0; // separate calls with a number to indicate this function has been called @@ -8352,6 +8360,11 @@ void dTree(GenTree* tree) cTree(JitTls::GetCompiler(), tree); } +void dTreeLIR(GenTree* tree) +{ + cTreeLIR(JitTls::GetCompiler(), tree); +} + void dTrees() { cTrees(JitTls::GetCompiler()); diff --git a/src/jit/compiler.h b/src/jit/compiler.h index be71875565ba..6108e847a1d4 100644 --- a/src/jit/compiler.h +++ b/src/jit/compiler.h @@ -2235,7 +2235,7 @@ class Compiler void gtDispTreeRange(LIR::Range& containingRange, GenTree* tree); - void gtDispLIRNode(GenTree* node); + void gtDispLIRNode(GenTree* node, const char* prefixMsg = nullptr); #endif // For tree walks diff --git a/src/jit/gentree.cpp b/src/jit/gentree.cpp index 3a9e8a011a0b..e65406b71765 100644 --- a/src/jit/gentree.cpp +++ b/src/jit/gentree.cpp @@ -12002,16 +12002,23 @@ 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, + size_t prefixIndent = 0) { assert(operand != nullptr); assert(message != nullptr); + if (prefixIndent != 0) + { + printf("%*s", (int)prefixIndent, ""); + } + // 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,11 +12029,16 @@ void Compiler::gtDispLIRNode(GenTree* node) operandArc = IIArc; printf(" t%-5d %-6s %s\n", operand->gtTreeID, varTypeName(operand->TypeGet()), message); - }; IndentStack indentStack(this); + size_t prefixIndent = 0; + if (prefixMsg != nullptr) + { + prefixIndent = strlen(prefixMsg); + } + const int bufLength = 256; char buf[bufLength]; @@ -12048,19 +12060,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, prefixIndent); } else if (operand == call->gtCallAddr) { - displayOperand(operand, "calli tgt", operandArc, indentStack); + displayOperand(operand, "calli tgt", operandArc, indentStack, prefixIndent); } else if (operand == call->gtControlExpr) { - displayOperand(operand, "control expr", operandArc, indentStack); + displayOperand(operand, "control expr", operandArc, indentStack, prefixIndent); } else if (operand == call->gtCallCookie) { - displayOperand(operand, "cookie", operandArc, indentStack); + displayOperand(operand, "cookie", operandArc, indentStack, prefixIndent); } else { @@ -12082,7 +12094,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, prefixIndent); operandArc = IIArc; } } @@ -12097,7 +12109,7 @@ void Compiler::gtDispLIRNode(GenTree* node) gtGetLateArgMsg(call, operand, curArgTabEntry->lateArgInx, -1, buf, sizeof(buf)); } - displayOperand(operand, buf, operandArc, indentStack); + displayOperand(operand, buf, operandArc, indentStack, prefixIndent); } } } @@ -12105,55 +12117,59 @@ void Compiler::gtDispLIRNode(GenTree* node) { if (operand == node->AsBlk()->Addr()) { - displayOperand(operand, "lhs", operandArc, indentStack); + displayOperand(operand, "lhs", operandArc, indentStack, prefixIndent); } else if (operand == node->AsBlk()->Data()) { - displayOperand(operand, "rhs", operandArc, indentStack); + displayOperand(operand, "rhs", operandArc, indentStack, prefixIndent); } else { assert(operand == node->AsDynBlk()->gtDynamicSize); - displayOperand(operand, "size", operandArc, indentStack); + displayOperand(operand, "size", operandArc, indentStack, prefixIndent); } } else if (node->OperGet() == GT_DYN_BLK) { if (operand == node->AsBlk()->Addr()) { - displayOperand(operand, "lhs", operandArc, indentStack); + displayOperand(operand, "lhs", operandArc, indentStack, prefixIndent); } else { assert(operand == node->AsDynBlk()->gtDynamicSize); - displayOperand(operand, "size", operandArc, indentStack); + displayOperand(operand, "size", operandArc, indentStack, prefixIndent); } } else if (node->OperIsAssignment()) { if (operand == node->gtGetOp1()) { - displayOperand(operand, "lhs", operandArc, indentStack); + displayOperand(operand, "lhs", operandArc, indentStack, prefixIndent); } else { - displayOperand(operand, "rhs", operandArc, indentStack); + displayOperand(operand, "rhs", operandArc, indentStack, prefixIndent); } } else { - displayOperand(operand, "", operandArc, indentStack); + displayOperand(operand, "", operandArc, indentStack, prefixIndent); } 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"); } /*****************************************************************************/