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 gtGetStructHandle and friends #84212

Merged
merged 11 commits into from
Apr 10, 2023
359 changes: 47 additions & 312 deletions src/coreclr/jit/compiler.h

Large diffs are not rendered by default.

10 changes: 4 additions & 6 deletions src/coreclr/jit/fginline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1658,14 +1658,12 @@ Statement* Compiler::fgInlinePrependStatements(InlineInfo* inlineInfo)

if (varTypeIsStruct(argType))
{
structHnd = gtGetStructHandleIfPresent(argNode);
noway_assert((structHnd != NO_CLASS_HANDLE) || (argType != TYP_STRUCT));
structHnd = lclVarInfo[argNum].lclVerTypeInfo.GetClassHandleForValueClass();
assert(structHnd != NO_CLASS_HANDLE);
Comment on lines +1661 to +1662
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the reason for the few diffs: previously, the struct handle could be "refined" to a type more specific than f(__Canon), which affects VN-based copy propagation.

The diffs could be fixed (i. e. made to not exist), but only with quirks, which I did not find worth it due to the already-not-small size of this change.

}

// Unsafe value cls check is not needed for
// argTmpNum here since in-linee compiler instance
// would have iterated over these and marked them
// accordingly.
// Unsafe value cls check is not needed for argTmpNum here since in-linee compiler instance
// would have iterated over these and marked them accordingly.
impAssignTempGen(tmpNum, argNode, structHnd, CHECK_SPILL_NONE, &afterStmt, callDI, block);

// We used to refine the temp type here based on
Expand Down
11 changes: 1 addition & 10 deletions src/coreclr/jit/flowgraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2146,16 +2146,7 @@ GenTree* Compiler::fgCreateMonitorTree(unsigned lvaMonAcquired, unsigned lvaThis
// ret(...) ->
// ret(comma(comma(tmp=...,call mon_exit), tmp))
//
//
// Before morph stage, it is possible to have a case of GT_RETURN(TYP_LONG, op1) where op1's type is
// TYP_STRUCT (of 8-bytes) and op1 is call node. See the big comment block in impReturnInstruction()
// for details for the case where info.compRetType is not the same as info.compRetNativeType. For
// this reason pass compMethodInfo->args.retTypeClass which is guaranteed to be a valid class handle
// if the return type is a value class. Note that fgInsertCommFormTemp() in turn uses this class handle
// if the type of op1 is TYP_STRUCT to perform lvaSetStruct() on the new temp that is created, which
// in turn passes it to VM to know the size of value type.
GenTree* temp = fgInsertCommaFormTemp(&retNode->AsOp()->gtOp1, info.compMethodInfo->args.retTypeClass);

GenTree* temp = fgInsertCommaFormTemp(&retNode->AsOp()->gtOp1);
GenTree* lclVar = retNode->AsOp()->gtOp1->AsOp()->gtOp2;

// The return can't handle all of the trees that could be on the right-hand-side of an assignment,
Expand Down
1,002 changes: 363 additions & 639 deletions src/coreclr/jit/gentree.cpp

Large diffs are not rendered by default.

23 changes: 4 additions & 19 deletions src/coreclr/jit/gentree.h
Original file line number Diff line number Diff line change
Expand Up @@ -571,9 +571,6 @@ enum GenTreeFlags : unsigned int
GTF_MDARRLEN_NONFAULTING = 0x20000000, // GT_MDARR_LENGTH -- An MD array length operation that cannot fault. Same as GT_IND_NONFAULTING.

GTF_MDARRLOWERBOUND_NONFAULTING = 0x20000000, // GT_MDARR_LOWER_BOUND -- An MD array lower bound operation that cannot fault. Same as GT_IND_NONFAULTING.

GTF_SIMDASHW_OP = 0x80000000, // GT_HWINTRINSIC -- Indicates that the structHandle should be gotten from gtGetStructHandleForSIMD
// rather than from gtGetStructHandleForHWSIMD.
};

inline constexpr GenTreeFlags operator ~(GenTreeFlags a)
Expand Down Expand Up @@ -6161,11 +6158,10 @@ struct GenTreeHWIntrinsic : public GenTreeJitIntrinsic
IntrinsicNodeBuilder&& nodeBuilder,
NamedIntrinsic hwIntrinsicID,
CorInfoType simdBaseJitType,
unsigned simdSize,
bool isSimdAsHWIntrinsic)
unsigned simdSize)
: GenTreeJitIntrinsic(GT_HWINTRINSIC, type, std::move(nodeBuilder), simdBaseJitType, simdSize)
{
Initialize(hwIntrinsicID, isSimdAsHWIntrinsic);
Initialize(hwIntrinsicID);
}

template <typename... Operands>
Expand All @@ -6174,11 +6170,10 @@ struct GenTreeHWIntrinsic : public GenTreeJitIntrinsic
NamedIntrinsic hwIntrinsicID,
CorInfoType simdBaseJitType,
unsigned simdSize,
bool isSimdAsHWIntrinsic,
Operands... operands)
: GenTreeJitIntrinsic(GT_HWINTRINSIC, type, allocator, simdBaseJitType, simdSize, operands...)
{
Initialize(hwIntrinsicID, isSimdAsHWIntrinsic);
Initialize(hwIntrinsicID);
}

#if DEBUGGABLE_GENTREE
Expand All @@ -6191,11 +6186,6 @@ struct GenTreeHWIntrinsic : public GenTreeJitIntrinsic
bool OperIsMemoryStore(GenTree** pAddr = nullptr) const;
bool OperIsMemoryLoadOrStore() const;

bool IsSimdAsHWIntrinsic() const
{
return (gtFlags & GTF_SIMDASHW_OP) != 0;
}

unsigned GetResultOpNumForFMA(GenTree* use, GenTree* op1, GenTree* op2, GenTree* op3);

ClassLayout* GetLayout(Compiler* compiler) const;
Expand Down Expand Up @@ -6289,7 +6279,7 @@ struct GenTreeHWIntrinsic : public GenTreeJitIntrinsic
private:
void SetHWIntrinsicId(NamedIntrinsic intrinsicId);

void Initialize(NamedIntrinsic intrinsicId, bool isSimdAsHWIntrinsic)
void Initialize(NamedIntrinsic intrinsicId)
{
SetHWIntrinsicId(intrinsicId);

Expand All @@ -6305,11 +6295,6 @@ struct GenTreeHWIntrinsic : public GenTreeJitIntrinsic
gtFlags |= GTF_ASG;
}
}

if (isSimdAsHWIntrinsic)
{
gtFlags |= GTF_SIMDASHW_OP;
}
}
};
#endif // FEATURE_HW_INTRINSICS
Expand Down
Loading