Skip to content

Commit fcce160

Browse files
authored
Don't force unused reg arg to the stack. (#44555)
* Don't force unused reg arg to the stack.
1 parent a505c46 commit fcce160

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/coreclr/src/jit/lsra.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5596,8 +5596,13 @@ void LinearScan::allocateRegisters()
55965596
{
55975597
allocate = false;
55985598
}
5599-
else if (refType == RefTypeParamDef && varDsc->lvRefCntWtd() <= BB_UNITY_WEIGHT)
5599+
else if (refType == RefTypeParamDef && (varDsc->lvRefCntWtd() <= BB_UNITY_WEIGHT) &&
5600+
(!currentRefPosition->lastUse || (currentInterval->physReg == REG_STK)))
56005601
{
5602+
// If this is a low ref-count parameter, and either it is used (def is not the last use) or it's
5603+
// passed on the stack, don't allocate a register.
5604+
// Note that if this is an unused register parameter we don't want to set allocate to false because that
5605+
// will cause us to allocate stack space to spill it.
56015606
allocate = false;
56025607
}
56035608
else if ((currentInterval->physReg == REG_STK) && nextRefPosition->treeNode->OperIs(GT_BITCAST))

0 commit comments

Comments
 (0)