From: SingleAccretion <62474226+SingleAccretion@users.noreply.github.com> Date: Thu, 11 May 2023 17:30:45 +0000 (+0300) Subject: Fix printing of arcs for local stores (#86098) X-Git-Tag: accepted/tizen/unified/riscv/20231226.055536~2291 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=47cb253236789befdafdb430cd1c852ca98b1bf9;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Fix printing of arcs for local stores (#86098) --- diff --git a/src/coreclr/jit/compiler.h b/src/coreclr/jit/compiler.h index 3022cd077a4..60e2129350c 100644 --- a/src/coreclr/jit/compiler.h +++ b/src/coreclr/jit/compiler.h @@ -3082,6 +3082,7 @@ public: void gtDispConst(GenTree* tree); void gtDispLeaf(GenTree* tree, IndentStack* indentStack); + void gtDispLocal(GenTreeLclVarCommon* tree, IndentStack* indentStack); void gtDispNodeName(GenTree* tree); #if FEATURE_MULTIREG_RET unsigned gtDispMultiRegCount(GenTree* tree); diff --git a/src/coreclr/jit/gentree.cpp b/src/coreclr/jit/gentree.cpp index f65ea1bc575..4c4f18d5bb2 100644 --- a/src/coreclr/jit/gentree.cpp +++ b/src/coreclr/jit/gentree.cpp @@ -11916,104 +11916,16 @@ void Compiler::gtDispLeaf(GenTree* tree, IndentStack* indentStack) return; } - bool isLclFld = false; char buffer[256]; switch (tree->gtOper) { - - case GT_LCL_FLD: - case GT_LCL_ADDR: - case GT_STORE_LCL_FLD: - isLclFld = true; - FALLTHROUGH; - case GT_PHI_ARG: case GT_LCL_VAR: - case GT_STORE_LCL_VAR: - { - printf(" "); - const unsigned varNum = tree->AsLclVarCommon()->GetLclNum(); - const LclVarDsc* varDsc = lvaGetDesc(varNum); - const bool isDef = (tree->gtFlags & GTF_VAR_DEF) != 0; - - gtDispLclVar(varNum); - gtDispSsaName(varNum, tree->AsLclVarCommon()->GetSsaNum(), isDef); - - if (isLclFld) - { - printf("[+%u]", tree->AsLclFld()->GetLclOffs()); - } - - if (varDsc->lvRegister) - { - printf(" "); - varDsc->PrintVarReg(); - } - else if (tree->InReg()) - { - printf(" %s", compRegVarName(tree->GetRegNum())); - } - - if (varDsc->lvPromoted) - { - if (!varTypeIsPromotable(varDsc) && !varDsc->lvUnusedStruct) - { - // Promoted implicit byrefs can get in this state while they are being rewritten - // in global morph. - } - else - { - for (unsigned index = 0; index < varDsc->lvFieldCnt; index++) - { - unsigned fieldLclNum = varDsc->lvFieldLclStart + index; - LclVarDsc* fieldVarDsc = lvaGetDesc(fieldLclNum); - const char* fieldName; -#if !defined(TARGET_64BIT) - if (varTypeIsLong(varDsc)) - { - fieldName = (index == 0) ? "lo" : "hi"; - } - else -#endif // !defined(TARGET_64BIT) - { - CORINFO_CLASS_HANDLE typeHnd = varDsc->GetLayout()->GetClassHandle(); - CORINFO_FIELD_HANDLE fldHnd = - info.compCompHnd->getFieldInClass(typeHnd, fieldVarDsc->lvFldOrdinal); - fieldName = eeGetFieldName(fldHnd, true, buffer, sizeof(buffer)); - } - - printf("\n"); - printf(" "); - printIndent(indentStack); - printf(" %-6s V%02u.%s (offs=0x%02x) -> ", varTypeName(fieldVarDsc->TypeGet()), - tree->AsLclVarCommon()->GetLclNum(), fieldName, fieldVarDsc->lvFldOffset); - gtDispLclVar(fieldLclNum); - gtDispSsaName(fieldLclNum, tree->AsLclVarCommon()->GetSsaNum(this, index), isDef); - - if (fieldVarDsc->lvRegister) - { - printf(" "); - fieldVarDsc->PrintVarReg(); - } - - if (fieldVarDsc->lvTracked && fgLocalVarLivenessDone && - tree->AsLclVarCommon()->IsLastUse(index)) - { - printf(" (last use)"); - } - } - } - } - else // a normal not-promoted lclvar - { - if (varDsc->lvTracked && fgLocalVarLivenessDone && ((tree->gtFlags & GTF_VAR_DEATH) != 0)) - { - printf(" (last use)"); - } - } - } - break; + case GT_LCL_FLD: + case GT_LCL_ADDR: + gtDispLocal(tree->AsLclVarCommon(), indentStack); + break; case GT_JMP: { @@ -12093,7 +12005,101 @@ void Compiler::gtDispLeaf(GenTree* tree, IndentStack* indentStack) } //------------------------------------------------------------------------ -// gtDispLeaf: Print a child node to jitstdout. +// gtDispLocal: Print description of a local node to jitstdout. +// +// Prints the information common to all local nodes. Does not print children. +// +// Arguments: +// tree - the local tree +// indentStack - the specification for the current level of indentation & arcs +// +void Compiler::gtDispLocal(GenTreeLclVarCommon* tree, IndentStack* indentStack) +{ + printf(" "); + const unsigned varNum = tree->GetLclNum(); + const LclVarDsc* varDsc = lvaGetDesc(varNum); + const bool isDef = (tree->gtFlags & GTF_VAR_DEF) != 0; + const bool isLclFld = tree->OperIsLocalField(); + + gtDispLclVar(varNum); + gtDispSsaName(varNum, tree->GetSsaNum(), isDef); + + if (isLclFld) + { + printf("[+%u]", tree->AsLclFld()->GetLclOffs()); + } + + if (varDsc->lvRegister) + { + printf(" "); + varDsc->PrintVarReg(); + } + else if (tree->InReg()) + { + printf(" %s", compRegVarName(tree->GetRegNum())); + } + + if (varDsc->lvPromoted) + { + if (!varTypeIsPromotable(varDsc) && !varDsc->lvUnusedStruct) + { + // Promoted implicit byrefs can get in this state while they are being rewritten + // in global morph. + } + else + { + char buffer[256]; + + for (unsigned index = 0; index < varDsc->lvFieldCnt; index++) + { + unsigned fieldLclNum = varDsc->lvFieldLclStart + index; + LclVarDsc* fieldVarDsc = lvaGetDesc(fieldLclNum); + const char* fieldName; +#if !defined(TARGET_64BIT) + if (varTypeIsLong(varDsc)) + { + fieldName = (index == 0) ? "lo" : "hi"; + } + else +#endif // !defined(TARGET_64BIT) + { + CORINFO_CLASS_HANDLE typeHnd = varDsc->GetLayout()->GetClassHandle(); + CORINFO_FIELD_HANDLE fldHnd = info.compCompHnd->getFieldInClass(typeHnd, fieldVarDsc->lvFldOrdinal); + fieldName = eeGetFieldName(fldHnd, true, buffer, sizeof(buffer)); + } + + printf("\n"); + printf(" "); + printIndent(indentStack); + printf(" %-6s V%02u.%s (offs=0x%02x) -> ", varTypeName(fieldVarDsc->TypeGet()), tree->GetLclNum(), + fieldName, fieldVarDsc->lvFldOffset); + gtDispLclVar(fieldLclNum); + gtDispSsaName(fieldLclNum, tree->GetSsaNum(this, index), isDef); + + if (fieldVarDsc->lvRegister) + { + printf(" "); + fieldVarDsc->PrintVarReg(); + } + + if (fieldVarDsc->lvTracked && fgLocalVarLivenessDone && tree->IsLastUse(index)) + { + printf(" (last use)"); + } + } + } + } + else // a normal not-promoted lclvar + { + if (varDsc->lvTracked && fgLocalVarLivenessDone && ((tree->gtFlags & GTF_VAR_DEATH) != 0)) + { + printf(" (last use)"); + } + } +} + +//------------------------------------------------------------------------ +// gtDispChild: Print a child node to jitstdout. // // Arguments: // tree - the tree to be printed @@ -12155,21 +12161,6 @@ void Compiler::gtDispTree(GenTree* tree, return; } - /* Is tree a leaf node? */ - - if (tree->OperIsLeaf() || tree->OperIsLocalStore()) // local stores used to be leaves - { - gtDispNode(tree, indentStack, msg, isLIR); - gtDispLeaf(tree, indentStack); - gtDispCommonEndLine(tree); - - if (tree->OperIsLocalStore() && !topOnly) - { - gtDispChild(tree->AsOp()->gtOp1, indentStack, IINone); - } - return; - } - // Determine what kind of arc to propagate. IndentInfo myArc = IINone; IndentInfo lowerArc = IINone; @@ -12244,7 +12235,11 @@ void Compiler::gtDispTree(GenTree* tree, printf(" %s <- %s", varTypeName(toType), varTypeName(fromType)); } - if (tree->OperIsBlkOp()) + if (tree->OperIsLocalStore()) // Local stores used to be leaf nodes. + { + gtDispLocal(tree->AsLclVarCommon(), indentStack); + } + else if (tree->OperIsBlkOp()) { if (tree->OperIsCopyBlkOp()) { @@ -12701,8 +12696,16 @@ void Compiler::gtDispTree(GenTree* tree, break; default: - printf(" :"); - printf(""); // null string means flush + if (tree->OperIsLeaf()) + { + gtDispLeaf(tree, indentStack); + gtDispCommonEndLine(tree); + } + else + { + printf(" :"); + printf(""); // null string means flush + } break; } } diff --git a/src/coreclr/jit/valuenum.cpp b/src/coreclr/jit/valuenum.cpp index e60ba90ca5e..46fcedc9b35 100644 --- a/src/coreclr/jit/valuenum.cpp +++ b/src/coreclr/jit/valuenum.cpp @@ -11252,7 +11252,11 @@ void Compiler::fgValueNumberTree(GenTree* tree) printTreeID(tree); printf(" "); gtDispNodeName(tree); - if (tree->OperIsLeaf() || tree->OperIsLocalStore()) // local stores used to be leaves + if (tree->OperIsLocalStore()) + { + gtDispLocal(tree->AsLclVarCommon(), nullptr); + } + else if (tree->OperIsLeaf()) { gtDispLeaf(tree, nullptr); }