Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JitDump improvements and other minor cleanup #92510

Merged
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
4 changes: 2 additions & 2 deletions src/coreclr/jit/codegen.h
Original file line number Diff line number Diff line change
Expand Up @@ -1051,11 +1051,11 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#endif // !defined(TARGET_64BIT)

//-------------------------------------------------------------------------
// genUpdateLifeStore: Do liveness udpate after tree store instructions
// genUpdateLifeStore: Do liveness update after tree store instructions
// were emitted, update result var's home if it was stored on stack.
//
// Arguments:
// tree - Gentree node
// tree - GenTree node
// targetReg - of the tree
// varDsc - result value's variable
//
Expand Down
6 changes: 3 additions & 3 deletions src/coreclr/jit/codegenarmarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4610,7 +4610,7 @@ void CodeGen::genLeaInstruction(GenTreeAddrMode* lea)
// addressing mode instruction. Currently we're 'cheating' by producing one or more
// instructions to generate the addressing mode so we need to modify lowering to
// produce LEAs that are a 1:1 relationship to the ARM64 architecture.
if (lea->Base() && lea->Index())
if (lea->HasBase() && lea->HasIndex())
{
GenTree* memBase = lea->Base();
GenTree* index = lea->Index();
Expand Down Expand Up @@ -4687,7 +4687,7 @@ void CodeGen::genLeaInstruction(GenTreeAddrMode* lea)
genScaledAdd(size, lea->GetRegNum(), memBase->GetRegNum(), index->GetRegNum(), scale);
}
}
else if (lea->Base())
else if (lea->HasBase())
{
GenTree* memBase = lea->Base();

Expand Down Expand Up @@ -4715,7 +4715,7 @@ void CodeGen::genLeaInstruction(GenTreeAddrMode* lea)
emit->emitIns_R_R_R(INS_add, size, lea->GetRegNum(), memBase->GetRegNum(), tmpReg);
}
}
else if (lea->Index())
else if (lea->HasIndex())
{
// If we encounter a GT_LEA node without a base it means it came out
// when attempting to optimize an arbitrary arithmetic expression during lower.
Expand Down
149 changes: 76 additions & 73 deletions src/coreclr/jit/codegencommon.cpp

Large diffs are not rendered by default.

17 changes: 9 additions & 8 deletions src/coreclr/jit/codegeninterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -667,21 +667,21 @@ class CodeGenInterface
class LiveRangeDumper
{
// Iterator to the first edited/added position during actual block code generation. If last
// block had a closed "VariableLiveRange" (with a valid "m_EndEmitLocation") and not changes
// block had a closed "VariableLiveRange" (with a valid "m_EndEmitLocation") and no changes
// were applied to variable liveness, it points to the end of variable's LiveRangeList.
LiveRangeListIterator m_StartingLiveRange;
bool m_hasLiveRangestoDump; // True if a live range for this variable has been
LiveRangeListIterator m_startingLiveRange;
bool m_hasLiveRangesToDump; // True if a live range for this variable has been
// reported from last call to EndBlock

public:
LiveRangeDumper(const LiveRangeList* liveRanges)
: m_StartingLiveRange(liveRanges->end()), m_hasLiveRangestoDump(false){};
: m_startingLiveRange(liveRanges->end()), m_hasLiveRangesToDump(false){};

// Make the dumper point to the last "VariableLiveRange" opened or nullptr if all are closed
void resetDumper(const LiveRangeList* list);

// Make "LiveRangeDumper" instance points the last "VariableLiveRange" added so we can
// start dumping from there after the actual "BasicBlock"s code is generated.
// Make "LiveRangeDumper" instance point at the last "VariableLiveRange" added so we can
// start dumping from there after the "BasicBlock"s code is generated.
void setDumperStartAt(const LiveRangeListIterator liveRangeIt);

// Return an iterator to the first "VariableLiveRange" edited/added during the current
Expand All @@ -703,10 +703,11 @@ class CodeGenInterface
class VariableLiveDescriptor
{
LiveRangeList* m_VariableLiveRanges; // the variable locations of this variable
INDEBUG(LiveRangeDumper* m_VariableLifeBarrier);
INDEBUG(LiveRangeDumper* m_VariableLifeBarrier;)
INDEBUG(unsigned m_varNum;)

public:
VariableLiveDescriptor(CompAllocator allocator);
VariableLiveDescriptor(CompAllocator allocator DEBUG_ARG(unsigned varNum));

bool hasVariableLiveRangeOpen() const;
LiveRangeList* getLiveRanges() const;
Expand Down
15 changes: 8 additions & 7 deletions src/coreclr/jit/codegenlinear.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -882,8 +882,8 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// None.
//
// Assumptions:
// The lclVar must be a register candidate (lvRegCandidate)

// The lclVar must be a register candidate (lvIsRegCandidate())
//
void CodeGen::genSpillVar(GenTree* tree)
{
unsigned varNum = tree->AsLclVarCommon()->GetLclNum();
Expand All @@ -892,7 +892,7 @@ void CodeGen::genSpillVar(GenTree* tree)
assert(varDsc->lvIsRegCandidate());

// We don't actually need to spill if it is already living in memory
bool needsSpill = ((tree->gtFlags & GTF_VAR_DEF) == 0 && varDsc->lvIsInReg());
const bool needsSpill = ((tree->gtFlags & GTF_VAR_DEF) == 0) && varDsc->lvIsInReg();
if (needsSpill)
{
// In order for a lclVar to have been allocated to a register, it must not have been aliasable, and can
Expand Down Expand Up @@ -954,7 +954,7 @@ void CodeGen::genSpillVar(GenTree* tree)

if (needsSpill)
{
// We need this after "lvRegNum" has change because now we are sure that varDsc->lvIsInReg() is false.
// We need this after "lvRegNum" has changed because now we are sure that varDsc->lvIsInReg() is false.
// "SiVarLoc" constructor uses the "LclVarDsc" of the variable.
varLiveKeeper->siUpdateVariableLiveRange(varDsc, varNum);
}
Expand Down Expand Up @@ -2106,10 +2106,11 @@ void CodeGen::genSpillLocal(unsigned varNum, var_types type, GenTreeLclVar* lclN
// node in codegen after code has been emitted for it.
//
// Arguments:
// tree - Gentree node
// tree - GenTree node
//
// Return Value:
// None.
//
void CodeGen::genProduceReg(GenTree* tree)
{
#ifdef DEBUG
Expand Down Expand Up @@ -2346,8 +2347,8 @@ void CodeGen::genEmitCallIndir(int callType,
int argSize = 0;
#endif // !defined(TARGET_X86)

regNumber iReg = (indir->Base() != nullptr) ? indir->Base()->GetRegNum() : REG_NA;
regNumber xReg = (indir->Index() != nullptr) ? indir->Index()->GetRegNum() : REG_NA;
regNumber iReg = indir->HasBase() ? indir->Base()->GetRegNum() : REG_NA;
regNumber xReg = indir->HasIndex() ? indir->Index()->GetRegNum() : REG_NA;

// These should have been put in volatile registers to ensure they do not
// get overridden by epilog sequence during tailcall.
Expand Down
6 changes: 3 additions & 3 deletions src/coreclr/jit/codegenloongarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7340,7 +7340,7 @@ void CodeGen::genLeaInstruction(GenTreeAddrMode* lea)
// addressing mode instruction. Currently we're 'cheating' by producing one or more
// instructions to generate the addressing mode so we need to modify lowering to
// produce LEAs that are a 1:1 relationship to the LOONGARCH64 architecture.
if (lea->Base() && lea->Index())
if (lea->HasBase() && lea->HasIndex())
{
GenTree* memBase = lea->Base();
GenTree* index = lea->Index();
Expand Down Expand Up @@ -7385,7 +7385,7 @@ void CodeGen::genLeaInstruction(GenTreeAddrMode* lea)
}
}
}
else if (lea->Base())
else if (lea->HasBase())
{
GenTree* memBase = lea->Base();

Expand Down Expand Up @@ -7416,7 +7416,7 @@ void CodeGen::genLeaInstruction(GenTreeAddrMode* lea)
emit->emitIns_R_R_R(INS_add_d, size, lea->GetRegNum(), memBase->GetRegNum(), tmpReg);
}
}
else if (lea->Index())
else if (lea->HasIndex())
{
// If we encounter a GT_LEA node without a base it means it came out
// when attempting to optimize an arbitrary arithmetic expression during lower.
Expand Down
6 changes: 3 additions & 3 deletions src/coreclr/jit/codegenriscv64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7005,7 +7005,7 @@ void CodeGen::genLeaInstruction(GenTreeAddrMode* lea)
// addressing mode instruction. Currently we're 'cheating' by producing one or more
// instructions to generate the addressing mode so we need to modify lowering to
// produce LEAs that are a 1:1 relationship to the RISCV64 architecture.
if (lea->Base() && lea->Index())
if (lea->HasBase() && lea->HasIndex())
{
GenTree* memBase = lea->Base();
GenTree* index = lea->Index();
Expand Down Expand Up @@ -7050,7 +7050,7 @@ void CodeGen::genLeaInstruction(GenTreeAddrMode* lea)
}
}
}
else if (lea->Base())
else if (lea->HasBase())
{
GenTree* memBase = lea->Base();

Expand Down Expand Up @@ -7081,7 +7081,7 @@ void CodeGen::genLeaInstruction(GenTreeAddrMode* lea)
emit->emitIns_R_R_R(INS_add, size, lea->GetRegNum(), memBase->GetRegNum(), tmpReg);
}
}
else if (lea->Index())
else if (lea->HasIndex())
{
// If we encounter a GT_LEA node without a base it means it came out
// when attempting to optimize an arbitrary arithmetic expression during lower.
Expand Down
6 changes: 3 additions & 3 deletions src/coreclr/jit/codegenxarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6664,17 +6664,17 @@ void CodeGen::genLeaInstruction(GenTreeAddrMode* lea)
emitAttr size = emitTypeSize(lea);
genConsumeOperands(lea);

if (lea->Base() && lea->Index())
if (lea->HasBase() && lea->HasIndex())
{
regNumber baseReg = lea->Base()->GetRegNum();
regNumber indexReg = lea->Index()->GetRegNum();
GetEmitter()->emitIns_R_ARX(INS_lea, size, lea->GetRegNum(), baseReg, indexReg, lea->gtScale, lea->Offset());
}
else if (lea->Base())
else if (lea->HasBase())
{
GetEmitter()->emitIns_R_AR(INS_lea, size, lea->GetRegNum(), lea->Base()->GetRegNum(), lea->Offset());
}
else if (lea->Index())
else if (lea->HasIndex())
{
GetEmitter()->emitIns_R_ARX(INS_lea, size, lea->GetRegNum(), REG_NA, lea->Index()->GetRegNum(), lea->gtScale,
lea->Offset());
Expand Down
25 changes: 16 additions & 9 deletions src/coreclr/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10480,7 +10480,13 @@ void GenTree::SetIndirExceptionFlags(Compiler* comp)
printf("%c", (flags & GTF_SET_FLAGS) ? 'S' : '-');
++charsDisplayed;
#endif
printf("%c", (flags & GTF_SPILLED) ? 'z' : (flags & GTF_SPILL) ? 'Z' : '-');

// Both GTF_SPILL and GTF_SPILLED: '#'
// Only GTF_SPILLED: 'z'
// Only GTF_SPILL: 'Z'
printf("%c", ((flags & (GTF_SPILL | GTF_SPILLED)) == (GTF_SPILL | GTF_SPILLED))
? '#'
: ((flags & GTF_SPILLED) ? 'z' : ((flags & GTF_SPILL) ? 'Z' : '-')));

return charsDisplayed;
}
Expand Down Expand Up @@ -10615,11 +10621,11 @@ void Compiler::gtDispNodeName(GenTree* tree)
{
GenTreeAddrMode* lea = tree->AsAddrMode();
bufp += SimpleSprintf_s(bufp, buf, sizeof(buf), " %s(", name);
if (lea->Base() != nullptr)
if (lea->HasBase())
{
bufp += SimpleSprintf_s(bufp, buf, sizeof(buf), "b+");
}
if (lea->Index() != nullptr)
if (lea->HasIndex())
{
bufp += SimpleSprintf_s(bufp, buf, sizeof(buf), "(i*%d)+", lea->gtScale);
}
Expand Down Expand Up @@ -11035,8 +11041,8 @@ void Compiler::gtDispNode(GenTree* tree, IndentStack* indentStack, _In_ _In_opt_
printf("%c", (flags & GTF_UNSIGNED ) ? 'U' :
(flags & GTF_BOOLEAN ) ? 'B' : '-');
printf("%c", (flags & GTF_SET_FLAGS ) ? 'S' : '-');
printf("%c", (flags & GTF_SPILLED ) ? 'z' : '-');
printf("%c", (flags & GTF_SPILL ) ? 'Z' : '-');
printf("%c", ((flags & (GTF_SPILL | GTF_SPILLED)) == (GTF_SPILL | GTF_SPILLED)) ? '#' : ((flags &
GTF_SPILLED) ? 'z' : ((flags & GTF_SPILL) ? 'Z' : '-')));
*/
}

Expand All @@ -11058,7 +11064,8 @@ void Compiler::gtDispNode(GenTree* tree, IndentStack* indentStack, _In_ _In_opt_
{
const size_t bufLength = msgLength - 1;
msg = reinterpret_cast<char*>(_alloca(bufLength * sizeof(char)));
sprintf_s(const_cast<char*>(msg), bufLength, "t%d = %s", tree->gtTreeID, hasOperands ? "" : " ");
sprintf_s(const_cast<char*>(msg), bufLength, "%c%d = %s", tree->IsUnusedValue() ? 'u' : 't', tree->gtTreeID,
hasOperands ? "" : " ");
}
}

Expand Down Expand Up @@ -11263,7 +11270,7 @@ unsigned Compiler::gtDispMultiRegCount(GenTree* tree)
// gtDispRegVal: Print the register(s) defined by the given node
//
// Arguments:
// tree - Gentree node whose registers we want to print
// tree - GenTree node whose registers we want to print
//
void Compiler::gtDispRegVal(GenTree* tree)
{
Expand Down Expand Up @@ -15869,8 +15876,8 @@ GenTree* Compiler::gtFoldExprConst(GenTree* tree)
// was successful - instead use one of the operands, e.g. op1.

// Don't fold overflow operations if not global morph phase.
// The reason for this is that this optimization is replacing a gentree node
// with another new gentree node. Say a GT_CALL(arglist) has one 'arg'
// The reason for this is that this optimization is replacing a GenTree node
// with another new GenTree node. Say a GT_CALL(arglist) has one 'arg'
// involving overflow arithmetic. During assertion prop, it is possible
// that the 'arg' could be constant folded and the result could lead to an
// overflow. In such a case 'arg' will get replaced with GT_COMMA node
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/jit/gentree.h
Original file line number Diff line number Diff line change
Expand Up @@ -7155,7 +7155,6 @@ struct GenTreeIndir : public GenTreeOp
return gtOp2;
}

// these methods provide an interface to the indirection node which
bool HasBase();
bool HasIndex();
GenTree* Base();
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/jit/importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9260,7 +9260,7 @@ void Compiler::impImportBlockCode(BasicBlock* block)
}

/* V4.0 allows assignment of i4 constant values to i8 type vars when IL verifier is bypassed (full
trust apps). The reason this works is that JIT stores an i4 constant in Gentree union during
trust apps). The reason this works is that JIT stores an i4 constant in GenTree union during
importation and reads from the union as if it were a long during code generation. Though this
can potentially read garbage, one can get lucky to have this working correctly.

Expand Down
8 changes: 4 additions & 4 deletions src/coreclr/jit/loopcloning.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void ArrIndex::PrintBoundsCheckNodes(unsigned dim /* = -1 */)
#endif // DEBUG

//--------------------------------------------------------------------------------------------------
// ToGenTree - Convert an arrLen operation into a gentree node.
// ToGenTree - Convert an arrLen operation into a GenTree node.
//
// Arguments:
// comp Compiler instance to allocate trees
Expand Down Expand Up @@ -111,7 +111,7 @@ GenTree* LC_Array::ToGenTree(Compiler* comp, BasicBlock* bb)
}

//--------------------------------------------------------------------------------------------------
// ToGenTree - Convert an "identifier" into a gentree node.
// ToGenTree - Convert an "identifier" into a GenTree node.
//
// Arguments:
// comp Compiler instance to allocate trees
Expand Down Expand Up @@ -170,7 +170,7 @@ GenTree* LC_Ident::ToGenTree(Compiler* comp, BasicBlock* bb)
}

//--------------------------------------------------------------------------------------------------
// ToGenTree - Convert an "expression" into a gentree node.
// ToGenTree - Convert an "expression" into a GenTree node.
//
// Arguments:
// comp Compiler instance to allocate trees
Expand All @@ -195,7 +195,7 @@ GenTree* LC_Expr::ToGenTree(Compiler* comp, BasicBlock* bb)
}

//--------------------------------------------------------------------------------------------------
// ToGenTree - Convert a "condition" into a gentree node.
// ToGenTree - Convert a "condition" into a GenTree node.
//
// Arguments:
// comp Compiler instance to allocate trees
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/jit/lower.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ class Lowering final : public Phase
// operands.
//
// Arguments:
// tree - Gentree of a binary operation.
// tree - GenTree of a binary operation.
// isSafeToMarkOp1 True if it's safe to mark op1 as register optional
// isSafeToMarkOp2 True if it's safe to mark op2 as register optional
//
Expand Down
Loading
Loading