Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete CLS_VAR #68524

Merged
merged 3 commits into from
Apr 28, 2022
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
12 changes: 0 additions & 12 deletions src/coreclr/jit/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9272,18 +9272,6 @@ void cTreeFlags(Compiler* comp, GenTree* tree)
}
break;

case GT_CLS_VAR:

if (tree->gtFlags & GTF_CLS_VAR_ASG_LHS)
{
chars += printf("[CLS_VAR_ASG_LHS]");
}
if (tree->gtFlags & GTF_CLS_VAR_TGT_HEAP)
{
chars += printf("[CLS_VAR_TGT_HEAP]");
}
break;

case GT_MUL:
#if !defined(TARGET_64BIT)
case GT_MUL_LONG:
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -10647,7 +10647,6 @@ class GenTreeVisitor
#endif // !FEATURE_EH_FUNCLETS
case GT_PHI_ARG:
case GT_JMPTABLE:
case GT_CLS_VAR:
case GT_CLS_VAR_ADDR:
case GT_PHYSREG:
case GT_EMITNOP:
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/jit/compiler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4197,7 +4197,6 @@ void GenTree::VisitOperands(TVisitor visitor)
#endif // !FEATURE_EH_FUNCLETS
case GT_PHI_ARG:
case GT_JMPTABLE:
case GT_CLS_VAR:
case GT_CLS_VAR_ADDR:
case GT_PHYSREG:
case GT_EMITNOP:
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/jit/emitarm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4031,7 +4031,7 @@ void emitter::emitIns_R_C(instruction ins, emitAttr attr, regNumber reg, CORINFO
return;
}

// Load address of CLS_VAR into a register
// Load address into a register
codeGen->instGen_Set_Reg_To_Imm(EA_HANDLE_CNS_RELOC, regTmp, addr);

if ((ins != INS_add) || (offs != 0) || (reg != regTmp))
Expand Down
15 changes: 4 additions & 11 deletions src/coreclr/jit/emitxarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2757,9 +2757,8 @@ inline UNATIVE_OFFSET emitter::emitInsSizeCV(instrDesc* id, code_t code)
instruction ins = id->idIns();
emitAttr attrSize = id->idOpSize();

// fgMorph changes any statics that won't fit into 32-bit addresses
// into constants with an indir, rather than GT_CLS_VAR
// so we should only hit this path for statics that are RIP-relative
// It is assumed that all addresses for the "M" format
// can be reached via RIP-relative addressing.
UNATIVE_OFFSET size = sizeof(INT32);

size += emitGetAdjustedSize(ins, attrSize, code);
Expand Down Expand Up @@ -3162,14 +3161,8 @@ void emitter::emitHandleMemOp(GenTreeIndir* indir, instrDesc* id, insFormat fmt,
// Static always need relocs
if (!jitStaticFldIsGlobAddr(fldHnd))
{
// Contract:
// fgMorphField() changes any statics that won't fit into 32-bit addresses into
// constants with an indir, rather than GT_CLS_VAR, based on reloc type hint given
// by VM. Hence emitter should always mark GT_CLS_VAR_ADDR as relocatable.
//
// Data section constants: these get allocated close to code block of the method and
// always addressable IP relative. These too should be marked as relocatable.

// "CLS_VAR_ADDR"s (currently only used for data section constants, which
// are addressable IP relative) are, by contract, always relocatable.
id->idSetIsDspReloc();
}

Expand Down
6 changes: 1 addition & 5 deletions src/coreclr/jit/fgdiagnostic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2973,10 +2973,6 @@ void Compiler::fgDebugCheckFlags(GenTree* tree)

switch (tree->OperGet())
{
case GT_CLS_VAR:
expectedFlags |= GTF_GLOB_REF;
break;

case GT_CATCH_ARG:
expectedFlags |= GTF_ORDER_SIDEEFF;
break;
Expand Down Expand Up @@ -3090,7 +3086,7 @@ void Compiler::fgDebugCheckFlags(GenTree* tree)
});

// ADDR nodes break the "parent flags >= operands flags" invariant for GTF_GLOB_REF.
if (tree->OperIs(GT_ADDR) && op1->OperIs(GT_LCL_VAR, GT_LCL_FLD, GT_CLS_VAR))
if (tree->OperIs(GT_ADDR) && op1->OperIs(GT_LCL_VAR, GT_LCL_FLD))
{
expectedFlags &= ~GTF_GLOB_REF;
}
Expand Down
3 changes: 1 addition & 2 deletions src/coreclr/jit/gcinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,8 +355,7 @@ GCInfo::WriteBarrierForm GCInfo::gcWriteBarrierFormFromTargetAddress(GenTree* tg

if (tgtAddr->OperGet() == GT_LCL_VAR)
{
unsigned lclNum = tgtAddr->AsLclVar()->GetLclNum();

unsigned lclNum = tgtAddr->AsLclVar()->GetLclNum();
LclVarDsc* varDsc = compiler->lvaGetDesc(lclNum);

// Instead of marking LclVar with 'lvStackByref',
Expand Down
35 changes: 0 additions & 35 deletions src/coreclr/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2398,14 +2398,6 @@ bool GenTree::Compare(GenTree* op1, GenTree* op2, bool swapOK)

return true;

case GT_CLS_VAR:
if (op1->AsClsVar()->gtClsVarHnd != op2->AsClsVar()->gtClsVarHnd)
{
break;
}

return true;

case GT_LABEL:
return true;

Expand Down Expand Up @@ -4622,14 +4614,6 @@ unsigned Compiler::gtSetEvalOrder(GenTree* tree)
#endif
break;

case GT_CLS_VAR:
#ifdef TARGET_ARM
// We generate movw/movt/ldr
level = 1;
costEx = 3 + IND_COST_EX; // 6
costSz = 4 + 4 + 2; // 10
break;
#endif
case GT_LCL_FLD:
level = 1;
costEx = IND_COST_EX;
Expand Down Expand Up @@ -5267,7 +5251,6 @@ unsigned Compiler::gtSetEvalOrder(GenTree* tree)

case GT_LCL_VAR:
case GT_LCL_FLD:
case GT_CLS_VAR:

// We evaluate op2 before op1
bReverseInAssignment = true;
Expand Down Expand Up @@ -5890,7 +5873,6 @@ bool GenTree::TryGetUse(GenTree* operand, GenTree*** pUse)
#endif // !FEATURE_EH_FUNCLETS
case GT_PHI_ARG:
case GT_JMPTABLE:
case GT_CLS_VAR:
case GT_CLS_VAR_ADDR:
case GT_PHYSREG:
case GT_EMITNOP:
Expand Down Expand Up @@ -8001,11 +7983,6 @@ GenTree* Compiler::gtClone(GenTree* tree, bool complexOK)
copy->AsLclFld()->SetFieldSeq(tree->AsLclFld()->GetFieldSeq());
break;

case GT_CLS_VAR:
copy = new (this, GT_CLS_VAR)
GenTreeClsVar(tree->gtType, tree->AsClsVar()->gtClsVarHnd, tree->AsClsVar()->gtFieldSeq);
break;

default:
if (!complexOK)
{
Expand Down Expand Up @@ -8193,11 +8170,6 @@ GenTree* Compiler::gtCloneExpr(
}
goto DONE;

case GT_CLS_VAR:
copy = new (this, GT_CLS_VAR)
GenTreeClsVar(tree->TypeGet(), tree->AsClsVar()->gtClsVarHnd, tree->AsClsVar()->gtFieldSeq);
goto DONE;

case GT_RET_EXPR:
// GT_RET_EXPR is unique node, that contains a link to a gtInlineCandidate node,
// that is part of another statement. We cannot clone both here and cannot
Expand Down Expand Up @@ -9132,7 +9104,6 @@ GenTreeUseEdgeIterator::GenTreeUseEdgeIterator(GenTree* node)
#endif // !FEATURE_EH_FUNCLETS
case GT_PHI_ARG:
case GT_JMPTABLE:
case GT_CLS_VAR:
case GT_CLS_VAR_ADDR:
case GT_PHYSREG:
case GT_EMITNOP:
Expand Down Expand Up @@ -10184,7 +10155,6 @@ void Compiler::gtDispNode(GenTree* tree, IndentStack* indentStack, _In_ _In_opt_
case GT_INDEX:
case GT_INDEX_ADDR:
case GT_FIELD:
case GT_CLS_VAR:
if (tree->gtFlags & GTF_IND_VOLATILE)
{
printf("V");
Expand Down Expand Up @@ -11291,11 +11261,6 @@ void Compiler::gtDispLeaf(GenTree* tree, IndentStack* indentStack)
}
break;

case GT_CLS_VAR:
printf(" Hnd=%#x", dspPtr(tree->AsClsVar()->gtClsVarHnd));
gtDispFieldSeq(tree->AsClsVar()->gtFieldSeq);
break;

case GT_CLS_VAR_ADDR:
printf(" Hnd=%#x", dspPtr(tree->AsClsVar()->gtClsVarHnd));
break;
Expand Down
29 changes: 7 additions & 22 deletions src/coreclr/jit/gentree.h
Original file line number Diff line number Diff line change
Expand Up @@ -487,9 +487,9 @@ enum GenTreeFlags : unsigned int

GTF_MEMORYBARRIER_LOAD = 0x40000000, // GT_MEMORYBARRIER -- Load barrier

GTF_FLD_VOLATILE = 0x40000000, // GT_FIELD/GT_CLS_VAR -- same as GTF_IND_VOLATILE
GTF_FLD_INITCLASS = 0x20000000, // GT_FIELD/GT_CLS_VAR -- field access requires preceding class/static init helper
GTF_FLD_TGT_HEAP = 0x10000000, // GT_FIELD/GT_CLS_VAR -- same as GTF_IND_TGT_HEAP
GTF_FLD_VOLATILE = 0x40000000, // GT_FIELD -- same as GTF_IND_VOLATILE
GTF_FLD_INITCLASS = 0x20000000, // GT_FIELD -- field access requires preceding class/static init helper
GTF_FLD_TGT_HEAP = 0x10000000, // GT_FIELD -- same as GTF_IND_TGT_HEAP

GTF_INX_RNGCHK = 0x80000000, // GT_INDEX/GT_INDEX_ADDR -- the array reference should be range-checked.
GTF_INX_STRING_LAYOUT = 0x40000000, // GT_INDEX -- this uses the special string array layout
Expand Down Expand Up @@ -517,12 +517,6 @@ enum GenTreeFlags : unsigned int
GTF_IND_FLAGS = GTF_IND_VOLATILE | GTF_IND_NONFAULTING | GTF_IND_TLS_REF | GTF_IND_UNALIGNED | GTF_IND_INVARIANT |
GTF_IND_NONNULL | GTF_IND_TGT_NOT_HEAP | GTF_IND_TGT_HEAP,

GTF_CLS_VAR_VOLATILE = 0x40000000, // GT_FIELD/GT_CLS_VAR -- same as GTF_IND_VOLATILE
GTF_CLS_VAR_INITCLASS = 0x20000000, // GT_FIELD/GT_CLS_VAR -- same as GTF_FLD_INITCLASS
GTF_CLS_VAR_TGT_HEAP = 0x10000000, // GT_FIELD/GT_CLS_VAR -- same as GTF_IND_TGT_HEAP
GTF_CLS_VAR_ASG_LHS = 0x04000000, // GT_CLS_VAR -- this GT_CLS_VAR node is (the effective val) of the LHS
// of an assignment; don't evaluate it independently.

GTF_ADDRMODE_NO_CSE = 0x80000000, // GT_ADD/GT_MUL/GT_LSH -- Do not CSE this node only, forms complex
// addressing mode

Expand Down Expand Up @@ -7160,24 +7154,15 @@ class StatementList
pointers) must be flagged as 'large' in GenTree::InitNodeSize().
*/

/* AsClsVar() -- 'static data member' (GT_CLS_VAR) */

// GenTreeClsVar: data address node (GT_CLS_VAR_ADDR).
//
struct GenTreeClsVar : public GenTree
{
CORINFO_FIELD_HANDLE gtClsVarHnd;
FieldSeqNode* gtFieldSeq;

GenTreeClsVar(var_types type, CORINFO_FIELD_HANDLE clsVarHnd, FieldSeqNode* fldSeq)
: GenTree(GT_CLS_VAR, type), gtClsVarHnd(clsVarHnd), gtFieldSeq(fldSeq)
{
gtFlags |= GTF_GLOB_REF;
}

GenTreeClsVar(genTreeOps oper, var_types type, CORINFO_FIELD_HANDLE clsVarHnd, FieldSeqNode* fldSeq)
: GenTree(oper, type), gtClsVarHnd(clsVarHnd), gtFieldSeq(fldSeq)
GenTreeClsVar(var_types type, CORINFO_FIELD_HANDLE clsVarHnd)
: GenTree(GT_CLS_VAR_ADDR, type), gtClsVarHnd(clsVarHnd)
{
assert((oper == GT_CLS_VAR) || (oper == GT_CLS_VAR_ADDR));
gtFlags |= GTF_GLOB_REF;
}

#if DEBUGGABLE_GENTREE
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/jit/gtlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ GTNODE(LABEL , GenTree ,0,GTK_LEAF) // Jump-ta
GTNODE(JMP , GenTreeVal ,0,GTK_LEAF|GTK_NOVALUE) // Jump to another function
GTNODE(FTN_ADDR , GenTreeFptrVal ,0,GTK_LEAF) // Address of a function
GTNODE(RET_EXPR , GenTreeRetExpr ,0,GTK_LEAF|DBK_NOTLIR) // Place holder for the return expression from an inline candidate
GTNODE(CLS_VAR , GenTreeClsVar ,0,GTK_LEAF) // Static data member

//-----------------------------------------------------------------------------
// Constant nodes:
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/jit/gtstructs.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ GTSTRUCT_1(ArrIndex , GT_ARR_INDEX)
GTSTRUCT_1(RetExpr , GT_RET_EXPR)
GTSTRUCT_1(ILOffset , GT_IL_OFFSET)
GTSTRUCT_2(CopyOrReload, GT_COPY, GT_RELOAD)
GTSTRUCT_2(ClsVar , GT_CLS_VAR, GT_CLS_VAR_ADDR)
GTSTRUCT_1(ClsVar , GT_CLS_VAR_ADDR)
GTSTRUCT_1(CmpXchg , GT_CMPXCHG)
GTSTRUCT_1(AddrMode , GT_LEA)
GTSTRUCT_N(Blk , GT_BLK, GT_STORE_BLK, GT_OBJ, GT_STORE_OBJ, GT_STORE_DYN_BLK)
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/jit/importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15637,7 +15637,7 @@ void Compiler::impImportBlockCode(BasicBlock* block)
// generated for ARM as well as x86, so the following IR will be accepted:
// STMTx (IL 0x... ???)
// * ASG long
// +--* CLS_VAR long
// +--* LCL_VAR long
// \--* CNS_INT int 2

if ((op1->TypeGet() != op2->TypeGet()) && op2->OperIsConst() && varTypeIsIntOrI(op2->TypeGet()) &&
Expand Down
22 changes: 1 addition & 21 deletions src/coreclr/jit/liveness.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,31 +224,11 @@ void Compiler::fgPerNodeLocalVarLiveness(GenTree* tree)
fgMarkUseDef(tree->AsLclVarCommon());
break;

case GT_CLS_VAR:
// For Volatile indirection, first mutate GcHeap/ByrefExposed.
// See comments in ValueNum.cpp (under case GT_CLS_VAR)
// This models Volatile reads as def-then-use of memory
// and allows for a CSE of a subsequent non-volatile read.
if ((tree->gtFlags & GTF_FLD_VOLATILE) != 0)
{
// For any Volatile indirection, we must handle it as a
// definition of GcHeap/ByrefExposed
fgCurMemoryDef |= memoryKindSet(GcHeap, ByrefExposed);
}
// If the GT_CLS_VAR is the lhs of an assignment, we'll handle it as a GcHeap/ByrefExposed def, when we get
// to the assignment.
// Otherwise, we treat it as a use here.
if ((tree->gtFlags & GTF_CLS_VAR_ASG_LHS) == 0)
{
fgCurMemoryUse |= memoryKindSet(GcHeap, ByrefExposed);
}
break;

case GT_IND:
case GT_OBJ:
case GT_BLK:
// For Volatile indirection, first mutate GcHeap/ByrefExposed
// see comments in ValueNum.cpp (under case GT_CLS_VAR)
// see comments in ValueNum.cpp (under the memory read case)
// This models Volatile reads as def-then-use of memory.
// and allows for a CSE of a subsequent non-volatile read
if ((tree->gtFlags & GTF_IND_VOLATILE) != 0)
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/jit/lower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7383,7 +7383,7 @@ void Lowering::LowerSIMD(GenTreeSIMD* simdNode)

CORINFO_FIELD_HANDLE hnd =
comp->GetEmitter()->emitBlkConst(constArgValues, cnsSize, cnsAlign, simdNode->GetSimdBaseType());
GenTree* clsVarAddr = new (comp, GT_CLS_VAR_ADDR) GenTreeClsVar(GT_CLS_VAR_ADDR, TYP_I_IMPL, hnd, nullptr);
GenTree* clsVarAddr = new (comp, GT_CLS_VAR_ADDR) GenTreeClsVar(TYP_I_IMPL, hnd);
BlockRange().InsertBefore(simdNode, clsVarAddr);
simdNode->ChangeOper(GT_IND);
simdNode->AsOp()->gtOp1 = clsVarAddr;
Expand Down
6 changes: 3 additions & 3 deletions src/coreclr/jit/lowerarmarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1169,9 +1169,9 @@ void Lowering::LowerHWIntrinsicCreate(GenTreeHWIntrinsic* node)
unsigned cnsAlign = cnsSize;
var_types dataType = Compiler::getSIMDTypeForSize(simdSize);

UNATIVE_OFFSET cnum = comp->GetEmitter()->emitDataConst(&vecCns, cnsSize, cnsAlign, dataType);
CORINFO_FIELD_HANDLE hnd = comp->eeFindJitDataOffs(cnum);
GenTree* clsVarAddr = new (comp, GT_CLS_VAR_ADDR) GenTreeClsVar(GT_CLS_VAR_ADDR, TYP_I_IMPL, hnd, nullptr);
UNATIVE_OFFSET cnum = comp->GetEmitter()->emitDataConst(&vecCns, cnsSize, cnsAlign, dataType);
CORINFO_FIELD_HANDLE hnd = comp->eeFindJitDataOffs(cnum);
GenTree* clsVarAddr = new (comp, GT_CLS_VAR_ADDR) GenTreeClsVar(TYP_I_IMPL, hnd);
BlockRange().InsertBefore(node, clsVarAddr);

node->ChangeOper(GT_IND);
Expand Down
6 changes: 3 additions & 3 deletions src/coreclr/jit/lowerxarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1546,9 +1546,9 @@ void Lowering::LowerHWIntrinsicCreate(GenTreeHWIntrinsic* node)
(comp->compCodeOpt() != Compiler::SMALL_CODE) ? cnsSize : emitter::dataSection::MIN_DATA_ALIGN;
var_types dataType = Compiler::getSIMDTypeForSize(simdSize);

UNATIVE_OFFSET cnum = comp->GetEmitter()->emitDataConst(&vecCns, cnsSize, cnsAlign, dataType);
CORINFO_FIELD_HANDLE hnd = comp->eeFindJitDataOffs(cnum);
GenTree* clsVarAddr = new (comp, GT_CLS_VAR_ADDR) GenTreeClsVar(GT_CLS_VAR_ADDR, TYP_I_IMPL, hnd, nullptr);
UNATIVE_OFFSET cnum = comp->GetEmitter()->emitDataConst(&vecCns, cnsSize, cnsAlign, dataType);
CORINFO_FIELD_HANDLE hnd = comp->eeFindJitDataOffs(cnum);
GenTree* clsVarAddr = new (comp, GT_CLS_VAR_ADDR) GenTreeClsVar(TYP_I_IMPL, hnd);
BlockRange().InsertBefore(node, clsVarAddr);

node->ChangeOper(GT_IND);
Expand Down
14 changes: 0 additions & 14 deletions src/coreclr/jit/lsraarm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -708,20 +708,6 @@ int LinearScan::BuildNode(GenTree* tree)
BuildDef(tree, RBM_EXCEPTION_OBJECT);
break;

case GT_CLS_VAR:
srcCount = 0;
// GT_CLS_VAR, by the time we reach the backend, must always
// be a pure use.
// It will produce a result of the type of the
// node, and use an internal register for the address.

assert(dstCount == 1);
assert((tree->gtFlags & (GTF_VAR_DEF | GTF_VAR_USEASG)) == 0);
buildInternalIntRegisterDefForNode(tree);
buildInternalRegisterUses();
BuildDef(tree);
break;

case GT_COPY:
srcCount = 1;
#ifdef TARGET_ARM
Expand Down
14 changes: 0 additions & 14 deletions src/coreclr/jit/lsraarm64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -761,20 +761,6 @@ int LinearScan::BuildNode(GenTree* tree)
BuildDef(tree, RBM_EXCEPTION_OBJECT);
break;

case GT_CLS_VAR:
srcCount = 0;
// GT_CLS_VAR, by the time we reach the backend, must always
// be a pure use.
// It will produce a result of the type of the
// node, and use an internal register for the address.

assert(dstCount == 1);
assert((tree->gtFlags & (GTF_VAR_DEF | GTF_VAR_USEASG)) == 0);
buildInternalIntRegisterDefForNode(tree);
buildInternalRegisterUses();
BuildDef(tree);
break;

case GT_INDEX_ADDR:
assert(dstCount == 1);
srcCount = BuildBinaryUses(tree->AsOp());
Expand Down
Loading