diff --git a/src/coreclr/jit/compiler.hpp b/src/coreclr/jit/compiler.hpp index 4e92a57cb006b9..01b4e612bf4d70 100644 --- a/src/coreclr/jit/compiler.hpp +++ b/src/coreclr/jit/compiler.hpp @@ -1242,7 +1242,12 @@ inline void GenTree::SetOper(genTreeOps oper, ValueNumberUpdate vnUpdate) case GT_CALL: new (&AsCall()->gtArgs, jitstd::placement_t()) CallArgs(); break; - +#ifdef DEBUG + case GT_LCL_VAR: + case GT_STORE_LCL_VAR: + AsLclVar()->ResetLclILoffs(); + break; +#endif default: break; } diff --git a/src/coreclr/jit/emit.h b/src/coreclr/jit/emit.h index e858a886029d55..8dfb47932f8448 100644 --- a/src/coreclr/jit/emit.h +++ b/src/coreclr/jit/emit.h @@ -607,6 +607,7 @@ class emitter unsigned idNum; size_t idSize; // size of the instruction descriptor unsigned idVarRefOffs; // IL offset for LclVar reference + unsigned idVarRefOffs2; // IL offset for 2nd LclVar reference (in case this is a pair) size_t idMemCookie; // compile time handle (check idFlags) GenTreeFlags idFlags; // for determining type of handle in idMemCookie bool idFinallyCall; // Branch instruction is a call to finally diff --git a/src/coreclr/jit/emitarm.cpp b/src/coreclr/jit/emitarm.cpp index 13b9c37ab529eb..f616dc99a8ab54 100644 --- a/src/coreclr/jit/emitarm.cpp +++ b/src/coreclr/jit/emitarm.cpp @@ -7836,7 +7836,7 @@ void emitter::emitDispFrameRef(int varx, int disp, int offs, bool asmfm) printf("]"); - if (varx >= 0 && emitComp->opts.varNames) + if ((varx >= 0) && emitComp->opts.varNames && (((IL_OFFSET)offs) != BAD_IL_OFFSET)) { const char* varName = emitComp->compLocalVarName(varx, offs); diff --git a/src/coreclr/jit/emitarm64.cpp b/src/coreclr/jit/emitarm64.cpp index c35b9c65732566..66ac2ba4f45d4a 100644 --- a/src/coreclr/jit/emitarm64.cpp +++ b/src/coreclr/jit/emitarm64.cpp @@ -6524,7 +6524,7 @@ void emitter::emitIns_R_R_R_I_LdStPair(instruction ins, int varx1, int varx2, int offs1, - int offs2) + int offs2 DEBUG_ARG(unsigned var1RefsOffs) DEBUG_ARG(unsigned var2RefsOffs)) { assert((ins == INS_stp) || (ins == INS_ldp)); emitAttr size = EA_SIZE(attr); @@ -6619,6 +6619,10 @@ void emitter::emitIns_R_R_R_I_LdStPair(instruction ins, id->idGCrefReg2(GCT_NONE); } +#ifdef DEBUG + id->idDebugOnlyInfo()->idVarRefOffs = var1RefsOffs; + id->idDebugOnlyInfo()->idVarRefOffs2 = var2RefsOffs; +#endif dispIns(id); appendToCurIG(id); } @@ -13922,11 +13926,18 @@ void emitter::emitDispInsHelp( break; } - if (id->idDebugOnlyInfo()->idVarRefOffs) + if (id->idIsLclVar()) { printf("\t// "); emitDispFrameRef(id->idAddr()->iiaLclVar.lvaVarNum(), id->idAddr()->iiaLclVar.lvaOffset(), id->idDebugOnlyInfo()->idVarRefOffs, asmfm); + if (id->idIsLclVarPair()) + { + printf(", "); + emitLclVarAddr* iiaLclVar2 = emitGetLclVarPairLclVar2(id); + emitDispFrameRef(iiaLclVar2->lvaVarNum(), iiaLclVar2->lvaOffset(), id->idDebugOnlyInfo()->idVarRefOffs2, + asmfm); + } } printf("\n"); @@ -13954,7 +13965,7 @@ void emitter::emitDispFrameRef(int varx, int disp, int offs, bool asmfm) printf("]"); - if (varx >= 0 && emitComp->opts.varNames) + if ((varx >= 0) && emitComp->opts.varNames && (((IL_OFFSET)offs) != BAD_IL_OFFSET)) { const char* varName = emitComp->compLocalVarName(varx, offs); @@ -16463,6 +16474,10 @@ bool emitter::ReplaceLdrStrWithPairInstr(instruction ins, } regNumber prevReg1 = emitLastIns->idReg1(); +#ifdef DEBUG + unsigned prevVarRefsOffs = emitLastIns->idDebugOnlyInfo()->idVarRefOffs; + unsigned newVarRefsOffs = emitVarRefOffs; +#endif ssize_t prevImm = emitGetInsSC(emitLastIns); instruction optIns = (ins == INS_ldr) ? INS_ldp : INS_stp; @@ -16513,12 +16528,12 @@ bool emitter::ReplaceLdrStrWithPairInstr(instruction ins, if (optimizationOrder == eRO_ascending) { emitIns_R_R_R_I_LdStPair(optIns, prevReg1Attr, reg1Attr, prevReg1, reg1, reg2, prevImmSize, prevLclVarNum, varx, - prevOffset, offs); + prevOffset, offs DEBUG_ARG(prevVarRefsOffs) DEBUG_ARG(newVarRefsOffs)); } else { emitIns_R_R_R_I_LdStPair(optIns, reg1Attr, prevReg1Attr, reg1, prevReg1, reg2, newImmSize, varx, prevLclVarNum, - offs, prevOffset); + offs, prevOffset DEBUG_ARG(newVarRefsOffs) DEBUG_ARG(prevVarRefsOffs)); } return true; diff --git a/src/coreclr/jit/emitarm64.h b/src/coreclr/jit/emitarm64.h index 240f4e03dd5858..59806d4b4ea252 100644 --- a/src/coreclr/jit/emitarm64.h +++ b/src/coreclr/jit/emitarm64.h @@ -873,7 +873,8 @@ void emitIns_R_R_R_I_LdStPair(instruction ins, int varx1 = -1, int varx2 = -1, int offs1 = -1, - int offs2 = -1); + int offs2 = -1 DEBUG_ARG(unsigned var1RefsOffs = BAD_IL_OFFSET) + DEBUG_ARG(unsigned var2RefsOffs = BAD_IL_OFFSET)); void emitIns_R_S(instruction ins, emitAttr attr, regNumber ireg, int varx, int offs); diff --git a/src/coreclr/jit/emitxarch.cpp b/src/coreclr/jit/emitxarch.cpp index 2e382fa231c14a..867af802c69200 100644 --- a/src/coreclr/jit/emitxarch.cpp +++ b/src/coreclr/jit/emitxarch.cpp @@ -10148,7 +10148,7 @@ void emitter::emitDispFrameRef(int varx, int disp, int offs, bool asmfm) printf("]"); #ifdef DEBUG - if (varx >= 0 && emitComp->opts.varNames) + if ((varx >= 0) && emitComp->opts.varNames && (((IL_OFFSET)offs) != BAD_IL_OFFSET)) { const char* varName = emitComp->compLocalVarName(varx, offs); diff --git a/src/coreclr/jit/gentree.h b/src/coreclr/jit/gentree.h index 1e8ebaa72721e9..ded20b5ae6a082 100644 --- a/src/coreclr/jit/gentree.h +++ b/src/coreclr/jit/gentree.h @@ -3685,6 +3685,13 @@ struct GenTreeLclVar : public GenTreeLclVarCommon this->gtSpillFlags = from->gtSpillFlags; } +#ifdef DEBUG + void ResetLclILoffs() + { + gtLclILoffs = BAD_IL_OFFSET; + } +#endif + GenTreeLclVar(genTreeOps oper, var_types type, unsigned lclNum DEBUGARG(IL_OFFSET ilOffs = BAD_IL_OFFSET) DEBUGARG(bool largeNode = false)) diff --git a/src/coreclr/jit/morph.cpp b/src/coreclr/jit/morph.cpp index 8c1bec692f269f..0805426e5e144a 100644 --- a/src/coreclr/jit/morph.cpp +++ b/src/coreclr/jit/morph.cpp @@ -14867,6 +14867,7 @@ void Compiler::fgMorphLocalField(GenTree* tree, GenTree* parent) tree->ChangeOper(GT_LCL_VAR); assert(tree->AsLclVarCommon()->GetLclNum() == fieldLclIndex); + tree->gtType = fldVarDsc->TypeGet(); if ((parent->gtOper == GT_ASG) && (parent->AsOp()->gtOp1 == tree)) diff --git a/src/coreclr/jit/morphblock.cpp b/src/coreclr/jit/morphblock.cpp index 52b912b0f6d707..31e6d49fd8bc49 100644 --- a/src/coreclr/jit/morphblock.cpp +++ b/src/coreclr/jit/morphblock.cpp @@ -566,6 +566,7 @@ void MorphInitBlockHelper::TryPrimitiveInit() m_asg->AsLclVar()->SetLclNum(m_dstLclNum); m_asg->gtFlags |= GTF_VAR_DEF; } + INDEBUG(m_dst->AsLclVar()->ResetLclILoffs()); m_result = m_asg; m_transformationDecision = BlockTransformation::OneAsgBlock;