Skip to content

Commit c0fbd99

Browse files
gtNewObjNode -> gtNewBlkIndir
1 parent 5f955d3 commit c0fbd99

6 files changed

Lines changed: 65 additions & 99 deletions

File tree

src/coreclr/jit/compiler.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2505,8 +2505,6 @@ class Compiler
25052505
GenTree* gtNewBitCastNode(var_types type, GenTree* arg);
25062506

25072507
public:
2508-
GenTreeBlk* gtNewObjNode(ClassLayout* layout, GenTree* addr);
2509-
GenTreeBlk* gtNewObjNode(CORINFO_CLASS_HANDLE structHnd, GenTree* addr);
25102508
GenTree* gtNewStructVal(ClassLayout* layout, GenTree* addr, GenTreeFlags indirFlags = GTF_EMPTY);
25112509

25122510
GenTreeCall* gtNewCallNode(gtCallTypes callType,
@@ -2845,6 +2843,8 @@ class Compiler
28452843

28462844
GenTreeMDArr* gtNewMDArrLowerBound(GenTree* arrayOp, unsigned dim, unsigned rank, BasicBlock* block);
28472845

2846+
GenTreeBlk* gtNewBlkIndir(ClassLayout* layout, GenTree* addr, GenTreeFlags indirFlags = GTF_EMPTY);
2847+
28482848
GenTreeIndir* gtNewIndir(var_types typ, GenTree* addr, GenTreeFlags indirFlags = GTF_EMPTY);
28492849

28502850
GenTree* gtNewNullCheck(GenTree* addr, BasicBlock* basicBlock);

src/coreclr/jit/compiler.hpp

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,7 +1076,7 @@ inline GenTreeIndir* Compiler::gtNewIndexIndir(GenTreeIndexAddr* indexAddr)
10761076
GenTreeIndir* index;
10771077
if (varTypeIsStruct(indexAddr->gtElemType))
10781078
{
1079-
index = gtNewObjNode(indexAddr->gtStructElemClass, indexAddr);
1079+
index = gtNewBlkIndir(typGetObjLayout(indexAddr->gtStructElemClass), indexAddr);
10801080
}
10811081
else
10821082
{
@@ -1177,16 +1177,58 @@ inline GenTreeMDArr* Compiler::gtNewMDArrLowerBound(GenTree* arrayOp, unsigned d
11771177
return arrOp;
11781178
}
11791179

1180-
//------------------------------------------------------------------------------
1181-
// gtNewIndir : Helper to create an indirection node.
1180+
//------------------------------------------------------------------------
1181+
// gtNewBlkIndir: Create a struct indirection node.
11821182
//
11831183
// Arguments:
1184-
// typ - Type of the node
1185-
// addr - Address of the indirection
1184+
// layout - The struct layout
1185+
// addr - Address of the indirection
1186+
// indirFlags - Indirection flags
11861187
//
11871188
// Return Value:
1188-
// New GT_IND node
1189+
// The created GT_BLK node.
1190+
//
1191+
inline GenTreeBlk* Compiler::gtNewBlkIndir(ClassLayout* layout, GenTree* addr, GenTreeFlags indirFlags)
1192+
{
1193+
assert((indirFlags & ~GTF_IND_FLAGS) == GTF_EMPTY);
1194+
1195+
GenTreeBlk* blkNode = new (this, GT_BLK) GenTreeBlk(GT_BLK, layout->GetType(), addr, layout);
1196+
blkNode->gtFlags |= indirFlags;
1197+
blkNode->SetIndirExceptionFlags(this);
11891198

1199+
// TODO-Bug: this method does not have enough information to make this determination.
1200+
// The local may end up (or already is) address-exposed.
1201+
if (addr->OperIs(GT_LCL_ADDR))
1202+
{
1203+
if (lvaIsImplicitByRefLocal(addr->AsLclVarCommon()->GetLclNum()))
1204+
{
1205+
blkNode->gtFlags |= GTF_GLOB_REF;
1206+
}
1207+
}
1208+
else
1209+
{
1210+
blkNode->gtFlags |= GTF_GLOB_REF;
1211+
}
1212+
1213+
if ((indirFlags & GTF_IND_VOLATILE) != 0)
1214+
{
1215+
blkNode->gtFlags |= GTF_ORDER_SIDEEFF;
1216+
}
1217+
1218+
return blkNode;
1219+
}
1220+
1221+
//------------------------------------------------------------------------------
1222+
// gtNewIndir : Create an indirection node.
1223+
//
1224+
// Arguments:
1225+
// typ - Type of the node
1226+
// addr - Address of the indirection
1227+
// indirFlags - Indirection flags
1228+
//
1229+
// Return Value:
1230+
// The created GT_IND node.
1231+
//
11901232
inline GenTreeIndir* Compiler::gtNewIndir(var_types typ, GenTree* addr, GenTreeFlags indirFlags)
11911233
{
11921234
assert((indirFlags & ~GTF_IND_FLAGS) == GTF_EMPTY);

src/coreclr/jit/gentree.cpp

Lines changed: 3 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -7812,57 +7812,6 @@ GenTreeOp* Compiler::gtNewAssignNode(GenTree* dst, GenTree* src)
78127812
return asg;
78137813
}
78147814

7815-
//------------------------------------------------------------------------
7816-
// gtNewObjNode: Creates a new BLK node with the given layout.
7817-
//
7818-
// Arguments:
7819-
// layout - The struct layout
7820-
// addr - The address of the struct
7821-
//
7822-
// Return Value:
7823-
// Returns a node representing the struct value at the given address.
7824-
//
7825-
GenTreeBlk* Compiler::gtNewObjNode(ClassLayout* layout, GenTree* addr)
7826-
{
7827-
assert(layout != nullptr);
7828-
7829-
GenTreeBlk* objNode = new (this, GT_BLK) GenTreeBlk(GT_BLK, layout->GetType(), addr, layout);
7830-
7831-
// TODO-Bug: this method does not have enough information to make this determination.
7832-
// The local may end up (or already is) address-exposed.
7833-
if (addr->OperIs(GT_LCL_ADDR))
7834-
{
7835-
if (lvaIsImplicitByRefLocal(addr->AsLclVarCommon()->GetLclNum()))
7836-
{
7837-
objNode->gtFlags |= GTF_GLOB_REF;
7838-
}
7839-
}
7840-
else
7841-
{
7842-
objNode->gtFlags |= GTF_GLOB_REF;
7843-
}
7844-
7845-
return objNode;
7846-
}
7847-
7848-
//------------------------------------------------------------------------
7849-
// gtNewObjNode: Creates a new BLK node with the layout for the given handle.
7850-
//
7851-
// Arguments:
7852-
// structHnd - The class handle of the struct type
7853-
// addr - The address of the struct
7854-
//
7855-
// Return Value:
7856-
// Returns a node representing the struct value at the given address.
7857-
//
7858-
GenTreeBlk* Compiler::gtNewObjNode(CORINFO_CLASS_HANDLE structHnd, GenTree* addr)
7859-
{
7860-
ClassLayout* layout = typGetObjLayout(structHnd);
7861-
GenTreeBlk* objNode = gtNewObjNode(layout, addr);
7862-
7863-
return objNode;
7864-
}
7865-
78667815
//------------------------------------------------------------------------
78677816
// gtNewStructVal: Return a node that represents a struct or block value
78687817
//
@@ -7879,8 +7828,7 @@ GenTree* Compiler::gtNewStructVal(ClassLayout* layout, GenTree* addr, GenTreeFla
78797828
{
78807829
assert((indirFlags & ~GTF_IND_FLAGS) == 0);
78817830

7882-
bool isVolatile = (indirFlags & GTF_IND_VOLATILE) != 0;
7883-
if (!isVolatile && addr->IsLclVarAddr())
7831+
if (((indirFlags & GTF_IND_VOLATILE) == 0) && addr->IsLclVarAddr())
78847832
{
78857833
unsigned lclNum = addr->AsLclFld()->GetLclNum();
78867834
LclVarDsc* varDsc = lvaGetDesc(lclNum);
@@ -7891,24 +7839,7 @@ GenTree* Compiler::gtNewStructVal(ClassLayout* layout, GenTree* addr, GenTreeFla
78917839
}
78927840
}
78937841

7894-
GenTreeBlk* blkNode;
7895-
if (layout->IsBlockLayout())
7896-
{
7897-
blkNode = new (this, GT_BLK) GenTreeBlk(GT_BLK, layout->GetType(), addr, layout);
7898-
}
7899-
else
7900-
{
7901-
blkNode = gtNewObjNode(layout, addr);
7902-
}
7903-
7904-
blkNode->gtFlags |= indirFlags;
7905-
if (isVolatile)
7906-
{
7907-
blkNode->gtFlags |= GTF_ORDER_SIDEEFF;
7908-
}
7909-
blkNode->SetIndirExceptionFlags(this);
7910-
7911-
return blkNode;
7842+
return gtNewBlkIndir(layout, addr, indirFlags);
79127843
}
79137844

79147845
//------------------------------------------------------------------------
@@ -15981,7 +15912,7 @@ GenTree* Compiler::gtNewRefCOMfield(GenTree* objPtr,
1598115912
{
1598215913
if (varTypeIsStruct(lclTyp))
1598315914
{
15984-
result = gtNewObjNode(structType, result);
15915+
result = gtNewBlkIndir(typGetObjLayout(structType), result);
1598515916
}
1598615917
else
1598715918
{

src/coreclr/jit/importer.cpp

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4311,10 +4311,10 @@ GenTree* Compiler::impImportStaticFieldAccess(CORINFO_RESOLVED_TOKEN* pResolvedT
43114311

43124312
if (!(access & CORINFO_ACCESS_ADDRESS))
43134313
{
4314+
// TODO-CQ: mark the indirections non-faulting.
43144315
if (varTypeIsStruct(lclTyp))
43154316
{
4316-
// Constructor adds GTF_GLOB_REF. Note that this is *not* GTF_EXCEPT.
4317-
op1 = gtNewObjNode(pFieldInfo->structType, op1);
4317+
op1 = gtNewBlkIndir(typGetObjLayout(pFieldInfo->structType), op1);
43184318
}
43194319
else
43204320
{
@@ -9386,8 +9386,7 @@ void Compiler::impImportBlockCode(BasicBlock* block)
93869386
{
93879387
if (varTypeIsStruct(lclTyp))
93889388
{
9389-
op1 = gtNewObjNode(fieldInfo.structType, op1);
9390-
op1->gtFlags |= GTF_IND_NONFAULTING;
9389+
op1 = gtNewBlkIndir(typGetObjLayout(fieldInfo.structType), op1, GTF_IND_NONFAULTING);
93919390
}
93929391
else
93939392
{
@@ -9666,8 +9665,7 @@ void Compiler::impImportBlockCode(BasicBlock* block)
96669665

96679666
if (varTypeIsStruct(lclTyp))
96689667
{
9669-
op1 = gtNewObjNode(fieldInfo.structType, op1);
9670-
op1->gtFlags |= GTF_IND_NONFAULTING;
9668+
op1 = gtNewBlkIndir(typGetObjLayout(fieldInfo.structType), op1, GTF_IND_NONFAULTING);
96719669
}
96729670
else
96739671
{
@@ -10813,17 +10811,13 @@ void Compiler::impImportBlockCode(BasicBlock* block)
1081310811
goto LDIND;
1081410812
}
1081510813

10816-
op1 = impPopStack().val;
10814+
GenTreeFlags indirFlags = impPrefixFlagsToIndirFlags(prefixFlags);
10815+
op1 = impPopStack().val;
1081710816

1081810817
assertImp((genActualType(op1) == TYP_I_IMPL) || op1->TypeIs(TYP_BYREF));
1081910818

10820-
op1 = gtNewObjNode(resolvedToken.hClass, op1);
10821-
op1->gtFlags |= GTF_EXCEPT;
10822-
op1->gtFlags |= impPrefixFlagsToIndirFlags(prefixFlags);
10823-
if (op1->AsIndir()->IsVolatile())
10824-
{
10825-
op1->gtFlags |= GTF_ORDER_SIDEEFF;
10826-
}
10819+
op1 = gtNewBlkIndir(typGetObjLayout(resolvedToken.hClass), op1, indirFlags);
10820+
op1->gtFlags |= GTF_EXCEPT; // TODO-1stClassStructs-Cleanup: delete this zero-diff quirk.
1082710821

1082810822
impPushOnStack(op1, tiRetVal);
1082910823
break;

src/coreclr/jit/importercalls.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2827,7 +2827,7 @@ GenTree* Compiler::impIntrinsic(GenTree* newobjThis,
28272827
var_types resultType = JITtype2varType(sig->retType);
28282828
if (resultType == TYP_STRUCT)
28292829
{
2830-
retNode = gtNewObjNode(sig->retTypeClass, lclVarAddr);
2830+
retNode = gtNewBlkIndir(typGetObjLayout(sig->retTypeClass), lclVarAddr);
28312831
}
28322832
else
28332833
{
@@ -5167,8 +5167,7 @@ GenTree* Compiler::impTransformThis(GenTree* thisPtr,
51675167
GenTree* obj = thisPtr;
51685168

51695169
assert(obj->TypeGet() == TYP_BYREF || obj->TypeGet() == TYP_I_IMPL);
5170-
obj = gtNewObjNode(pConstrainedResolvedToken->hClass, obj);
5171-
obj->gtFlags |= GTF_EXCEPT;
5170+
obj = gtNewBlkIndir(typGetObjLayout(pConstrainedResolvedToken->hClass), obj);
51725171

51735172
CorInfoType jitTyp = info.compCompHnd->asCorInfoType(pConstrainedResolvedToken->hClass);
51745173
if (impIsPrimitive(jitTyp))
@@ -8887,7 +8886,7 @@ GenTree* Compiler::impArrayAccessIntrinsic(
88878886
{
88888887
if (varTypeIsStruct(elemType))
88898888
{
8890-
arrElem = gtNewObjNode(sig->retTypeClass, arrElem);
8889+
arrElem = gtNewBlkIndir(typGetObjLayout(sig->retTypeClass), arrElem);
88918890
}
88928891
else
88938892
{

src/coreclr/jit/morph.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15036,7 +15036,7 @@ PhaseStatus Compiler::fgRetypeImplicitByRefArgs()
1503615036
GenTree* lhs = gtNewLclvNode(newLclNum, varDsc->lvType);
1503715037
// RHS is an indirection (using GT_BLK) off the parameter.
1503815038
GenTree* addr = gtNewLclvNode(lclNum, TYP_BYREF);
15039-
GenTree* rhs = (varDsc->TypeGet() == TYP_STRUCT) ? gtNewObjNode(varDsc->GetLayout(), addr)
15039+
GenTree* rhs = (varDsc->TypeGet() == TYP_STRUCT) ? gtNewBlkIndir(varDsc->GetLayout(), addr)
1504015040
: gtNewIndir(varDsc->TypeGet(), addr);
1504115041
GenTree* assign = gtNewAssignNode(lhs, rhs);
1504215042
fgNewStmtAtBeg(fgFirstBB, assign);

0 commit comments

Comments
 (0)