Skip to content

Commit 5c479bb

Browse files
authored
Skip allocation for ZeroInit writeThru intervals (#58677)
* Do not allocate register if ZeroInit/EHWriteThru * Update the comments about zero-init heuristics * jit format
1 parent 83f6621 commit 5c479bb

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/coreclr/jit/lclvars.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4108,8 +4108,10 @@ void Compiler::lvaMarkLclRefs(GenTree* tree, BasicBlock* block, Statement* stmt,
41084108
{
41094109
bool bbInALoop = (block->bbFlags & BBF_BACKWARD_JUMP) != 0;
41104110
bool bbIsReturn = block->bbJumpKind == BBJ_RETURN;
4111-
// TODO: Zero-inits in LSRA are created with below condition. Try to use similar condition here as well.
4112-
// if (compiler->info.compInitMem || varTypeIsGC(varDsc->TypeGet()))
4111+
// TODO: Zero-inits in LSRA are created with below condition. But if filter out based on that condition
4112+
// we filter lot of interesting variables that would benefit otherwise with EH var enregistration.
4113+
// bool needsExplicitZeroInit = !varDsc->lvIsParam && (info.compInitMem ||
4114+
// varTypeIsGC(varDsc->TypeGet()));
41134115
bool needsExplicitZeroInit = fgVarNeedsExplicitZeroInit(lclNum, bbInALoop, bbIsReturn);
41144116

41154117
if (varDsc->lvSingleDefRegCandidate || needsExplicitZeroInit)

src/coreclr/jit/lsra.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4945,6 +4945,13 @@ void LinearScan::allocateRegisters()
49454945
// it to a different register file.
49464946
allocate = false;
49474947
}
4948+
else if ((currentInterval->isWriteThru) && (refType == RefTypeZeroInit))
4949+
{
4950+
// For RefTypeZeroInit which is a write thru, there is no need to allocate register
4951+
// right away. It can be assigned when actually definition occurs.
4952+
// In future, see if avoiding allocation for RefTypeZeroInit gives any benefit in general.
4953+
allocate = false;
4954+
}
49484955
if (!allocate)
49494956
{
49504957
INDEBUG(dumpLsraAllocationEvent(LSRA_EVENT_NO_ENTRY_REG_ALLOCATED, currentInterval));

0 commit comments

Comments
 (0)