Skip to content

Commit

Permalink
Revert "Unpin locals (dotnet#70264)"
Browse files Browse the repository at this point in the history
This reverts commit b1c2275.
  • Loading branch information
jkotas committed Jun 12, 2022
1 parent 5c5e66e commit ddc0b20
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 57 deletions.
2 changes: 0 additions & 2 deletions src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -614,8 +614,6 @@ class LclVarDsc
unsigned char lvSingleDefDisqualifyReason = 'H';
#endif

unsigned char lvAllDefsAreNoGc : 1; // For pinned locals: true if all defs of this local are no-gc

#if FEATURE_MULTIREG_ARGS
regNumber lvRegNumForSlot(unsigned slotNum)
{
Expand Down
5 changes: 0 additions & 5 deletions src/coreclr/jit/gentree.h
Original file line number Diff line number Diff line change
Expand Up @@ -1109,11 +1109,6 @@ struct GenTree
return true;
}

bool IsNotGcDef() const
{
return IsIntegralConst(0) || IsLocalAddrExpr();
}

// LIR flags
// These helper methods, along with the flag values they manipulate, are defined in lir.h
//
Expand Down
80 changes: 30 additions & 50 deletions src/coreclr/jit/lclvars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4181,57 +4181,49 @@ void Compiler::lvaMarkLclRefs(GenTree* tree, BasicBlock* block, Statement* stmt,

/* Is this an assignment to a local variable? */

if (op1->gtOper == GT_LCL_VAR)
if (op1->gtOper == GT_LCL_VAR && op2->gtType != TYP_BOOL)
{
LclVarDsc* varDsc = lvaGetDesc(op1->AsLclVarCommon());
/* Only simple assignments allowed for booleans */

if (varDsc->lvPinned && varDsc->lvAllDefsAreNoGc)
if (tree->gtOper != GT_ASG)
{
if (!op2->IsNotGcDef())
{
varDsc->lvAllDefsAreNoGc = false;
}
goto NOT_BOOL;
}

if (op2->gtType != TYP_BOOL)
{
/* Only simple assignments allowed for booleans */
/* Is the RHS clearly a boolean value? */

if (tree->gtOper != GT_ASG)
{
goto NOT_BOOL;
}
switch (op2->gtOper)
{
unsigned lclNum;

/* Is the RHS clearly a boolean value? */
case GT_CNS_INT:

switch (op2->gtOper)
{
case GT_CNS_INT:
if (op2->AsIntCon()->gtIconVal == 0)
{
break;
}
if (op2->AsIntCon()->gtIconVal == 1)
{
break;
}

if (op2->AsIntCon()->gtIconVal == 0)
{
break;
}
if (op2->AsIntCon()->gtIconVal == 1)
{
break;
}
// Not 0 or 1, fall through ....
FALLTHROUGH;

// Not 0 or 1, fall through ....
FALLTHROUGH;
default:

default:
if (op2->OperIsCompare())
{
break;
}

if (op2->OperIsCompare())
{
break;
}
NOT_BOOL:

NOT_BOOL:
lclNum = op1->AsLclVarCommon()->GetLclNum();
noway_assert(lclNum < lvaCount);

varDsc->lvIsBoolean = false;
break;
}
lvaTable[lclNum].lvIsBoolean = false;
break;
}
}
}
Expand Down Expand Up @@ -4286,8 +4278,7 @@ void Compiler::lvaMarkLclRefs(GenTree* tree, BasicBlock* block, Statement* stmt,
{
if (lvaVarAddrExposed(lclNum))
{
varDsc->lvIsBoolean = false;
varDsc->lvAllDefsAreNoGc = false;
varDsc->lvIsBoolean = false;
}

if (tree->gtOper == GT_LCL_FLD)
Expand Down Expand Up @@ -4712,8 +4703,6 @@ void Compiler::lvaComputeRefCounts(bool isRecompute, bool setSlotNumbers)
varDsc->setLvRefCnt(0);
varDsc->setLvRefCntWtd(BB_ZERO_WEIGHT);

varDsc->lvAllDefsAreNoGc = true;

// Special case for some varargs params ... these must
// remain unreferenced.
const bool isSpecialVarargsParam = varDsc->lvIsParam && raIsVarargsStackArg(lclNum);
Expand Down Expand Up @@ -4761,8 +4750,6 @@ void Compiler::lvaComputeRefCounts(bool isRecompute, bool setSlotNumbers)
{
varDsc->lvSingleDef = varDsc->lvIsParam;
varDsc->lvSingleDefRegCandidate = varDsc->lvIsParam;

varDsc->lvAllDefsAreNoGc = true;
}
}

Expand Down Expand Up @@ -4881,13 +4868,6 @@ void Compiler::lvaComputeRefCounts(bool isRecompute, bool setSlotNumbers)
varDsc->lvImplicitlyReferenced = 1;
}
}

if (varDsc->lvPinned && varDsc->lvAllDefsAreNoGc)
{
varDsc->lvPinned = 0;

JITDUMP("V%02u was unpinned as all def candidates were local.\n", lclNum);
}
}
}

Expand Down

0 comments on commit ddc0b20

Please sign in to comment.