Skip to content

Commit 98203d3

Browse files
committed
review feedback
1 parent ca42b6e commit 98203d3

File tree

5 files changed

+24
-16
lines changed

5 files changed

+24
-16
lines changed

src/coreclr/jit/codegencommon.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ void CodeGenInterface::genUpdateRegLife(const LclVarDsc* varDsc, bool isBorn, bo
554554
// If this is going live, the register must not have a variable in it, except
555555
// in the case of an exception or "spill at single-def" variable, which may be already treated
556556
// as live in the register.
557-
assert(varDsc->lvLiveInOutOfHndlr || varDsc->lvSpillAtSingleDef || ((regSet.GetMaskVars() & regMask) == 0));
557+
assert(varDsc->IsAlwaysAliveInMemory() || ((regSet.GetMaskVars() & regMask) == 0));
558558
regSet.AddMaskVars(regMask);
559559
}
560560
}
@@ -736,7 +736,7 @@ void Compiler::compChangeLife(VARSET_VALARG_TP newLife)
736736
bool isGCRef = (varDsc->TypeGet() == TYP_REF);
737737
bool isByRef = (varDsc->TypeGet() == TYP_BYREF);
738738
bool isInReg = varDsc->lvIsInReg();
739-
bool isInMemory = !isInReg || varDsc->lvLiveInOutOfHndlr || varDsc->lvSpillAtSingleDef;
739+
bool isInMemory = !isInReg || varDsc->IsAlwaysAliveInMemory();
740740

741741
if (isInReg)
742742
{
@@ -778,7 +778,7 @@ void Compiler::compChangeLife(VARSET_VALARG_TP newLife)
778778
{
779779
// If this variable is going live in a register, it is no longer live on the stack,
780780
// unless it is an EH/"spill at single-def" var, which always remains live on the stack.
781-
if (!varDsc->lvLiveInOutOfHndlr && !varDsc->lvSpillAtSingleDef)
781+
if (!varDsc->IsAlwaysAliveInMemory())
782782
{
783783
#ifdef DEBUG
784784
if (VarSetOps::IsMember(this, codeGen->gcInfo.gcVarPtrSetCur, bornVarIndex))
@@ -11428,7 +11428,7 @@ void CodeGen::genMultiRegStoreToLocal(GenTreeLclVar* lclNode)
1142811428
{
1142911429
varReg = REG_STK;
1143011430
}
11431-
if ((varReg == REG_STK) || fieldVarDsc->lvLiveInOutOfHndlr || fieldVarDsc->lvSpillAtSingleDef)
11431+
if ((varReg == REG_STK) || fieldVarDsc->IsAlwaysAliveInMemory())
1143211432
{
1143311433
if (!lclNode->AsLclVar()->IsLastUse(i))
1143411434
{

src/coreclr/jit/codegenlinear.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ void CodeGen::genCodeForBBlist()
229229
{
230230
newRegByrefSet |= varDsc->lvRegMask();
231231
}
232-
if (!varDsc->lvLiveInOutOfHndlr && !varDsc->lvSpillAtSingleDef)
232+
if (!varDsc->IsAlwaysAliveInMemory())
233233
{
234234
#ifdef DEBUG
235235
if (verbose && VarSetOps::IsMember(compiler, gcInfo.gcVarPtrSetCur, varIndex))
@@ -240,8 +240,7 @@ void CodeGen::genCodeForBBlist()
240240
VarSetOps::RemoveElemD(compiler, gcInfo.gcVarPtrSetCur, varIndex);
241241
}
242242
}
243-
if ((!varDsc->lvIsInReg() || varDsc->lvLiveInOutOfHndlr || varDsc->lvSpillAtSingleDef) &&
244-
compiler->lvaIsGCTracked(varDsc))
243+
if ((!varDsc->lvIsInReg() || varDsc->IsAlwaysAliveInMemory()) && compiler->lvaIsGCTracked(varDsc))
245244
{
246245
#ifdef DEBUG
247246
if (verbose && !VarSetOps::IsMember(compiler, gcInfo.gcVarPtrSetCur, varIndex))
@@ -876,7 +875,7 @@ void CodeGen::genSpillVar(GenTree* tree)
876875

877876
// If this is a write-thru or a single-def variable, we don't actually spill at a use,
878877
// but we will kill the var in the reg (below).
879-
if (!varDsc->lvLiveInOutOfHndlr && !varDsc->lvSpillAtSingleDef)
878+
if (!varDsc->IsAlwaysAliveInMemory())
880879
{
881880
instruction storeIns = ins_Store(lclType, compiler->isSIMDTypeLocalAligned(varNum));
882881
assert(varDsc->GetRegNum() == tree->GetRegNum());
@@ -921,7 +920,7 @@ void CodeGen::genSpillVar(GenTree* tree)
921920
{
922921
// We only have 'GTF_SPILL' and 'GTF_SPILLED' on a def of a write-thru lclVar
923922
// or a single-def var that is to be spilled at its definition.
924-
assert((varDsc->lvLiveInOutOfHndlr || varDsc->lvSpillAtSingleDef) && ((tree->gtFlags & GTF_VAR_DEF) != 0));
923+
assert((varDsc->IsAlwaysAliveInMemory()) && ((tree->gtFlags & GTF_VAR_DEF) != 0));
925924
}
926925

927926
#ifdef USING_VARIABLE_LIVE_RANGE
@@ -1057,7 +1056,7 @@ void CodeGen::genUnspillLocal(
10571056
}
10581057
#endif // USING_VARIABLE_LIVE_RANGE
10591058

1060-
if (!varDsc->lvLiveInOutOfHndlr && !varDsc->lvSpillAtSingleDef)
1059+
if (!varDsc->IsAlwaysAliveInMemory())
10611060
{
10621061
#ifdef DEBUG
10631062
if (VarSetOps::IsMember(compiler, gcInfo.gcVarPtrSetCur, varDsc->lvVarIndex))
@@ -2057,7 +2056,7 @@ void CodeGen::genSpillLocal(unsigned varNum, var_types type, GenTreeLclVar* lclN
20572056
// spilled, i.e. write-thru. Likewise, single-def vars that are spilled at its definitions).
20582057
// An EH or single-def var use is always valid on the stack (so we don't need to actually spill it),
20592058
// but the GTF_SPILL flag records the fact that the register value is going dead.
2060-
if (((lclNode->gtFlags & GTF_VAR_DEF) != 0) || (!varDsc->lvLiveInOutOfHndlr && !varDsc->lvSpillAtSingleDef))
2059+
if (((lclNode->gtFlags & GTF_VAR_DEF) != 0) || (!varDsc->IsAlwaysAliveInMemory()))
20612060
{
20622061
// Store local variable to its home location.
20632062
// Ensure that lclVar stores are typed correctly.

src/coreclr/jit/compiler.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,6 +1030,16 @@ class LclVarDsc
10301030
return GetRegisterType() != TYP_UNDEF;
10311031
}
10321032

1033+
//-----------------------------------------------------------------------------
1034+
// IsAlwaysAliveInMemory: Determines if this variable's value is always
1035+
// up-to-date on stack. This is possible if this is an EH-var or
1036+
// we decided to spill after single-def.
1037+
//
1038+
bool IsAlwaysAliveInMemory() const
1039+
{
1040+
return lvLiveInOutOfHndlr || lvSpillAtSingleDef;
1041+
}
1042+
10331043
bool CanBeReplacedWithItsField(Compiler* comp) const;
10341044

10351045
#ifdef DEBUG

src/coreclr/jit/lsra.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3274,8 +3274,7 @@ void LinearScan::spillInterval(Interval* interval, RefPosition* fromRefPosition
32743274
}
32753275
}
32763276

3277-
// Only handle the singledef intervals whose firstRefPosition is RefTypeDef and is not already marked as spillAfter
3278-
// yet.
3277+
// Only handle the singledef intervals whose firstRefPosition is RefTypeDef and is not yet marked as spillAfter.
32793278
// The singledef intervals whose firstRefPositions are already marked as spillAfter, no need to mark them as
32803279
// singleDefSpill because they will always get spilled at firstRefPosition.
32813280
// This helps in spilling the singleDef at definition

src/coreclr/jit/treelifeupdater.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ bool TreeLifeUpdater<ForCodeGen>::UpdateLifeFieldVar(GenTreeLclVar* lclNode, uns
6060
{
6161
regNumber reg = lclNode->GetRegNumByIdx(multiRegIndex);
6262
bool isInReg = fldVarDsc->lvIsInReg() && reg != REG_NA;
63-
isInMemory = !isInReg || fldVarDsc->lvLiveInOutOfHndlr || fldVarDsc->lvSpillAtSingleDef;
63+
isInMemory = !isInReg || fldVarDsc->IsAlwaysAliveInMemory();
6464
if (isInReg)
6565
{
6666
if (isBorn)
@@ -259,7 +259,7 @@ void TreeLifeUpdater<ForCodeGen>::UpdateLifeVar(GenTree* tree)
259259
compiler->codeGen->genUpdateVarReg(varDsc, tree);
260260
}
261261
bool isInReg = varDsc->lvIsInReg() && tree->GetRegNum() != REG_NA;
262-
bool isInMemory = !isInReg || varDsc->lvLiveInOutOfHndlr || varDsc->lvSpillAtSingleDef;
262+
bool isInMemory = !isInReg || varDsc->IsAlwaysAliveInMemory();
263263
if (isInReg)
264264
{
265265
compiler->codeGen->genUpdateRegLife(varDsc, isBorn, isDying DEBUGARG(tree));
@@ -283,7 +283,7 @@ void TreeLifeUpdater<ForCodeGen>::UpdateLifeVar(GenTree* tree)
283283
unsigned fldVarIndex = fldVarDsc->lvVarIndex;
284284
regNumber reg = lclVarTree->AsLclVar()->GetRegNumByIdx(i);
285285
bool isInReg = fldVarDsc->lvIsInReg() && reg != REG_NA;
286-
bool isInMemory = !isInReg || fldVarDsc->lvLiveInOutOfHndlr || fldVarDsc->lvSpillAtSingleDef;
286+
bool isInMemory = !isInReg || fldVarDsc->IsAlwaysAliveInMemory();
287287
bool isFieldDying = lclVarTree->AsLclVar()->IsLastUse(i);
288288
if ((isBorn && !isFieldDying) || (!isBorn && isFieldDying))
289289
{

0 commit comments

Comments
 (0)