Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 3360765

Browse files
author
Sergey Andreenko
authored
[RyuJit] Delete contained workaround. (#15257)
* Move CodeGen::indirForm and IntForm to common. * GenTreeFieldList: SetContained only for the head. * delete the workaround. * move check from isContained to CheckLIR `isContained` can't determinate does node has user or not. Move this check to the appropriate place. * check that SetContained and IsContained are consistent.
1 parent d39e739 commit 3360765

File tree

7 files changed

+39
-66
lines changed

7 files changed

+39
-66
lines changed

src/jit/codegenarmarch.cpp

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1538,35 +1538,6 @@ void CodeGen::genCodeForArrOffset(GenTreeArrOffs* arrOffset)
15381538
genProduceReg(arrOffset);
15391539
}
15401540

1541-
//------------------------------------------------------------------------
1542-
// indirForm: Make a temporary indir we can feed to pattern matching routines
1543-
// in cases where we don't want to instantiate all the indirs that happen.
1544-
//
1545-
GenTreeIndir CodeGen::indirForm(var_types type, GenTree* base)
1546-
{
1547-
GenTreeIndir i(GT_IND, type, base, nullptr);
1548-
i.gtRegNum = REG_NA;
1549-
i.SetContained();
1550-
// has to be nonnull (because contained nodes can't be the last in block)
1551-
// but don't want it to be a valid pointer
1552-
i.gtNext = (GenTree*)(-1);
1553-
return i;
1554-
}
1555-
1556-
//------------------------------------------------------------------------
1557-
// intForm: Make a temporary int we can feed to pattern matching routines
1558-
// in cases where we don't want to instantiate.
1559-
//
1560-
GenTreeIntCon CodeGen::intForm(var_types type, ssize_t value)
1561-
{
1562-
GenTreeIntCon i(type, value);
1563-
i.gtRegNum = REG_NA;
1564-
// has to be nonnull (because contained nodes can't be the last in block)
1565-
// but don't want it to be a valid pointer
1566-
i.gtNext = (GenTree*)(-1);
1567-
return i;
1568-
}
1569-
15701541
//------------------------------------------------------------------------
15711542
// genCodeForShift: Generates the code sequence for a GenTree node that
15721543
// represents a bit shift or rotate operation (<<, >>, >>>, rol, ror).
@@ -1693,7 +1664,6 @@ void CodeGen::genCodeForIndexAddr(GenTreeIndexAddr* node)
16931664
GenTreeAddrMode arrLenAddr(base->TypeGet(), base, nullptr, 0, static_cast<unsigned>(node->gtLenOffset));
16941665
arrLenAddr.gtRegNum = REG_NA;
16951666
arrLenAddr.SetContained();
1696-
arrLenAddr.gtNext = (GenTree*)(-1);
16971667

16981668
GenTreeIndir arrLen = indirForm(TYP_INT, &arrLenAddr);
16991669
arrLen.gtRegNum = tmpReg;

src/jit/codegencommon.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12606,3 +12606,30 @@ const char* CodeGen::siStackVarName(size_t offs, size_t size, unsigned reg, unsi
1260612606
#endif // !defined(DEBUG)
1260712607
#endif // defined(LATE_DISASM)
1260812608
/*****************************************************************************/
12609+
12610+
#ifndef LEGACY_BACKEND
12611+
12612+
//------------------------------------------------------------------------
12613+
// indirForm: Make a temporary indir we can feed to pattern matching routines
12614+
// in cases where we don't want to instantiate all the indirs that happen.
12615+
//
12616+
GenTreeIndir CodeGen::indirForm(var_types type, GenTree* base)
12617+
{
12618+
GenTreeIndir i(GT_IND, type, base, nullptr);
12619+
i.gtRegNum = REG_NA;
12620+
i.SetContained();
12621+
return i;
12622+
}
12623+
12624+
//------------------------------------------------------------------------
12625+
// intForm: Make a temporary int we can feed to pattern matching routines
12626+
// in cases where we don't want to instantiate.
12627+
//
12628+
GenTreeIntCon CodeGen::intForm(var_types type, ssize_t value)
12629+
{
12630+
GenTreeIntCon i(type, value);
12631+
i.gtRegNum = REG_NA;
12632+
return i;
12633+
}
12634+
12635+
#endif // !LEGACY_BACKEND

src/jit/codegenxarch.cpp

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4032,33 +4032,6 @@ void CodeGen::genCodeForArrOffset(GenTreeArrOffs* arrOffset)
40324032
genProduceReg(arrOffset);
40334033
}
40344034

4035-
// make a temporary indir we can feed to pattern matching routines
4036-
// in cases where we don't want to instantiate all the indirs that happen
4037-
//
4038-
GenTreeIndir CodeGen::indirForm(var_types type, GenTree* base)
4039-
{
4040-
GenTreeIndir i(GT_IND, type, base, nullptr);
4041-
i.gtRegNum = REG_NA;
4042-
i.SetContained();
4043-
// has to be nonnull (because contained nodes can't be the last in block)
4044-
// but don't want it to be a valid pointer
4045-
i.gtNext = (GenTree*)(-1);
4046-
return i;
4047-
}
4048-
4049-
// make a temporary int we can feed to pattern matching routines
4050-
// in cases where we don't want to instantiate
4051-
//
4052-
GenTreeIntCon CodeGen::intForm(var_types type, ssize_t value)
4053-
{
4054-
GenTreeIntCon i(type, value);
4055-
i.gtRegNum = REG_NA;
4056-
// has to be nonnull (because contained nodes can't be the last in block)
4057-
// but don't want it to be a valid pointer
4058-
i.gtNext = (GenTree*)(-1);
4059-
return i;
4060-
}
4061-
40624035
instruction CodeGen::genGetInsForOper(genTreeOps oper, var_types type)
40634036
{
40644037
instruction ins;
@@ -4581,7 +4554,6 @@ void CodeGen::genCodeForIndexAddr(GenTreeIndexAddr* node)
45814554
GenTreeAddrMode arrLenAddr(base->TypeGet(), base, nullptr, 0, node->gtLenOffset);
45824555
arrLenAddr.gtRegNum = REG_NA;
45834556
arrLenAddr.SetContained();
4584-
arrLenAddr.gtNext = (GenTree*)(-1);
45854557

45864558
GenTreeIndir arrLen = indirForm(TYP_INT, &arrLenAddr);
45874559

@@ -4603,7 +4575,6 @@ void CodeGen::genCodeForIndexAddr(GenTreeIndexAddr* node)
46034575

46044576
arrLen.gtRegNum = REG_NA;
46054577
arrLen.SetContained();
4606-
arrLen.gtNext = (GenTree*)(-1);
46074578
}
46084579

46094580
// Generate the range check.

src/jit/gentree.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16514,10 +16514,10 @@ bool GenTree::isContained() const
1651416514
assert(!isMarkedContained);
1651516515
}
1651616516

16517-
// if it's contained it better have a user
16517+
// if it's contained it can't be unused.
1651816518
if (isMarkedContained)
1651916519
{
16520-
assert(gtNext != nullptr);
16520+
assert(!IsUnusedValue());
1652116521
}
1652216522
#endif // DEBUG
1652316523
return isMarkedContained;

src/jit/gentree.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2067,6 +2067,7 @@ struct GenTree
20672067
{
20682068
assert(IsValue());
20692069
gtFlags |= GTF_CONTAINED;
2070+
assert(isContained());
20702071
}
20712072

20722073
void ClearContained()
@@ -3182,16 +3183,16 @@ struct GenTreeFieldList : public GenTreeArgList
31823183
if (prevList == nullptr)
31833184
{
31843185
gtFlags |= GTF_FIELD_LIST_HEAD;
3186+
#ifndef LEGACY_BACKEND
3187+
// A GT_FIELD_LIST head is always contained. Other nodes return false from IsValue()
3188+
// and should not be marked as contained.
3189+
SetContained();
3190+
#endif
31853191
}
31863192
else
31873193
{
31883194
prevList->gtOp2 = this;
31893195
}
3190-
#ifndef LEGACY_BACKEND
3191-
// A GT_FIELD_LIST is always contained. Note that this should only matter for the head node, but
3192-
// the list may be reordered.
3193-
gtFlags |= GTF_CONTAINED;
3194-
#endif
31953196
}
31963197
};
31973198

src/jit/lir.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1664,6 +1664,7 @@ bool LIR::Range::CheckLIR(Compiler* compiler, bool checkUnusedValues) const
16641664
{
16651665
GenTree* node = kvp.Key();
16661666
assert(node->IsUnusedValue() && "found an unmarked unused value");
1667+
assert(!node->isContained() && "a contained node should have a user");
16671668
}
16681669
}
16691670

src/jit/lowerxarch.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,9 @@ void Lowering::LowerPutArgStk(GenTreePutArgStk* putArgStk)
463463
if (head != fieldList)
464464
{
465465
head->gtFlags |= GTF_FIELD_LIST_HEAD;
466+
head->SetContained();
467+
468+
fieldList->ClearContained();
466469
fieldList->gtFlags &= ~GTF_FIELD_LIST_HEAD;
467470

468471
#ifdef DEBUG

0 commit comments

Comments
 (0)