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

Commit

Permalink
Remove bogus code
Browse files Browse the repository at this point in the history
gtNewObjNode always returns GT_OBJ nodes.
  • Loading branch information
mikedn committed Jul 14, 2019
1 parent ad00177 commit e695bf4
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 34 deletions.
2 changes: 1 addition & 1 deletion src/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -2455,7 +2455,7 @@ class Compiler
void gtBlockOpInit(GenTree* result, GenTree* dst, GenTree* srcOrFillVal, bool isVolatile);

public:
GenTree* gtNewObjNode(CORINFO_CLASS_HANDLE structHnd, GenTree* addr);
GenTreeObj* gtNewObjNode(CORINFO_CLASS_HANDLE structHnd, GenTree* addr);
void gtSetObjGcInfo(GenTreeObj* objNode);
GenTree* gtNewStructVal(CORINFO_CLASS_HANDLE structHnd, GenTree* addr);
GenTree* gtNewBlockVal(GenTree* addr, unsigned size);
Expand Down
28 changes: 4 additions & 24 deletions src/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6184,42 +6184,22 @@ GenTree* Compiler::gtNewAssignNode(GenTree* dst, GenTree* src)
// addr - The address of the struct.
//
// Return Value:
// Returns a node representing the struct value at the given address.
// Returns a GT_OBJ node representing the struct value at the given address.
//
// Notes:
// It will currently return a GT_OBJ node for any struct type, but may
// return a GT_IND or a non-indirection for a scalar type.

GenTree* Compiler::gtNewObjNode(CORINFO_CLASS_HANDLE structHnd, GenTree* addr)
GenTreeObj* Compiler::gtNewObjNode(CORINFO_CLASS_HANDLE structHnd, GenTree* addr)
{
var_types nodeType = impNormStructType(structHnd);
assert(varTypeIsStruct(nodeType));

if (!varTypeIsStruct(nodeType))
{
if ((addr->gtOper == GT_ADDR) && (addr->gtGetOp1()->TypeGet() == nodeType))
{
return addr->gtGetOp1();
}
else
{
return gtNewOperNode(GT_IND, nodeType, addr);
}
}

GenTreeObj* objNode = new (this, GT_OBJ) GenTreeObj(nodeType, addr, typGetObjLayout(structHnd));

// An Obj is not a global reference, if it is known to be a local struct.
if ((addr->gtFlags & GTF_GLOB_REF) == 0)
{
GenTreeLclVarCommon* lclNode = addr->IsLocalAddrExpr();
if (lclNode != nullptr)
if ((lclNode != nullptr) && !lvaIsImplicitByRefLocal(lclNode->GetLclNum()))
{
objNode->gtFlags |= GTF_IND_NONFAULTING;
if (!lvaIsImplicitByRefLocal(lclNode->gtLclNum))
{
objNode->gtFlags &= ~GTF_GLOB_REF;
}
objNode->gtFlags &= ~GTF_GLOB_REF;
}
}
return objNode;
Expand Down
4 changes: 4 additions & 0 deletions src/jit/gentree.h
Original file line number Diff line number Diff line change
Expand Up @@ -4816,6 +4816,10 @@ struct GenTreeObj : public GenTreeBlk
{
// By default, an OBJ is assumed to be a global reference, unless it is local.
GenTreeLclVarCommon* lcl = Addr()->IsLocalAddrExpr();
if (lcl != nullptr)
{
gtFlags |= GTF_IND_NONFAULTING;
}
if ((lcl == nullptr) || ((lcl->gtFlags & GTF_GLOB_EFFECT) != 0))
{
gtFlags |= GTF_GLOB_REF;
Expand Down
10 changes: 2 additions & 8 deletions src/jit/morph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9887,10 +9887,7 @@ GenTree* Compiler::fgMorphBlkNode(GenTree* tree, bool isDest)
else
{
tree = gtNewObjNode(structHnd, addr);
if (tree->OperGet() == GT_OBJ)
{
gtSetObjGcInfo(tree->AsObj());
}
gtSetObjGcInfo(tree->AsObj());
}
}
else
Expand Down Expand Up @@ -10057,10 +10054,7 @@ GenTree* Compiler::fgMorphBlockOperand(GenTree* tree, var_types asgType, unsigne
else
{
newTree = gtNewObjNode(clsHnd, addr);
if (newTree->OperGet() == GT_OBJ)
{
gtSetObjGcInfo(newTree->AsObj());
}
gtSetObjGcInfo(newTree->AsObj());
}
}
else
Expand Down
2 changes: 1 addition & 1 deletion src/jit/rationalize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ void Rationalizer::RewriteAssignment(LIR::Use& use)
if (varDsc->HasGCPtr())
{
CORINFO_CLASS_HANDLE structHnd = varDsc->lvVerTypeInfo.GetClassHandle();
GenTreeObj* objNode = comp->gtNewObjNode(structHnd, location)->AsObj();
GenTreeObj* objNode = comp->gtNewObjNode(structHnd, location);
objNode->ChangeOper(GT_STORE_OBJ);
objNode->SetData(value);
comp->fgMorphUnsafeBlk(objNode);
Expand Down

0 comments on commit e695bf4

Please sign in to comment.