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
6 changes: 4 additions & 2 deletions src/coreclr/jit/lclvars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4142,8 +4142,10 @@ void Compiler::lvaMarkLclRefs(GenTree* tree, BasicBlock* block, Statement* stmt,
{
bool bbInALoop = (block->bbFlags & BBF_BACKWARD_JUMP) != 0;
bool bbIsReturn = block->bbJumpKind == BBJ_RETURN;
// TODO: Zero-inits in LSRA are created with below condition. Try to use similar condition here as well.
// if (compiler->info.compInitMem || varTypeIsGC(varDsc->TypeGet()))
// TODO: Zero-inits in LSRA are created with below condition. But if filter out based on that condition
// we filter lot of interesting variables that would benefit otherwise with EH var enregistration.
// bool needsExplicitZeroInit = !varDsc->lvIsParam && (info.compInitMem ||
// varTypeIsGC(varDsc->TypeGet()));
bool needsExplicitZeroInit = fgVarNeedsExplicitZeroInit(lclNum, bbInALoop, bbIsReturn);

if (varDsc->lvSingleDefRegCandidate || needsExplicitZeroInit)
Expand Down
7 changes: 7 additions & 0 deletions src/coreclr/jit/lsra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4945,6 +4945,13 @@ void LinearScan::allocateRegisters()
// it to a different register file.
allocate = false;
}
else if ((currentInterval->isWriteThru) && (refType == RefTypeZeroInit))
{
// For RefTypeZeroInit which is a write thru, there is no need to allocate register
// right away. It can be assigned when actually definition occurs.
// In future, see if avoiding allocation for RefTypeZeroInit gives any benefit in general.
allocate = false;
}
if (!allocate)
{
INDEBUG(dumpLsraAllocationEvent(LSRA_EVENT_NO_ENTRY_REG_ALLOCATED, currentInterval));
Expand Down