Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/coreclr/jit/compiler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/jit/emit.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Comment on lines 609 to +610
Copy link
Contributor

@SingleAccretion SingleAccretion May 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these IL offsets actually maintained/set/used enough to care about them? Last time I checked the logic, that was not the case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently they are not. The only place they are used currently is in emitDispFrameRef() under a flag compiler->opts.varNames which is always false. Added this to retain the consistency, when (if) we re-enable varNames functionality.

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
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/jit/emitarm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
25 changes: 20 additions & 5 deletions src/coreclr/jit/emitarm64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/coreclr/jit/emitarm64.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/jit/emitxarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
7 changes: 7 additions & 0 deletions src/coreclr/jit/gentree.h
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/jit/morph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/jit/morphblock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down