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

Commit

Permalink
Use ClassLayout in GenTreeCall
Browse files Browse the repository at this point in the history
  • Loading branch information
mikedn committed May 5, 2019
1 parent e77a594 commit 867ab3f
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 16 deletions.
10 changes: 6 additions & 4 deletions src/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5831,7 +5831,6 @@ GenTreeCall* Compiler::gtNewCallNode(
node->gtCallObjp = nullptr;
node->fgArgInfo = nullptr;
node->callSig = nullptr;
node->gtRetClsHnd = nullptr;
node->gtControlExpr = nullptr;
node->gtCallMoreFlags = 0;

Expand Down Expand Up @@ -7493,7 +7492,10 @@ GenTreeCall* Compiler::gtCloneExprCallHelper(GenTreeCall* tree, unsigned addFlag
copy->fgArgInfo = nullptr;
}

copy->gtRetClsHnd = tree->gtRetClsHnd;
if (varTypeIsStruct(tree->TypeGet()))
{
copy->SetLayout(tree->GetLayout());
}

#if FEATURE_MULTIREG_RET
copy->gtReturnTypeDesc = tree->gtReturnTypeDesc;
Expand Down Expand Up @@ -16452,7 +16454,7 @@ CORINFO_CLASS_HANDLE Compiler::gtGetStructHandleIfPresent(GenTree* tree)
{
CORINFO_CLASS_HANDLE structHnd = NO_CLASS_HANDLE;
tree = tree->gtEffectiveVal();
if (varTypeIsStruct(tree->gtType))
if (varTypeIsStruct(tree->TypeGet()))
{
switch (tree->gtOper)
{
Expand All @@ -16465,7 +16467,7 @@ CORINFO_CLASS_HANDLE Compiler::gtGetStructHandleIfPresent(GenTree* tree)
structHnd = tree->AsObj()->GetLayout()->GetClassHandle();
break;
case GT_CALL:
structHnd = tree->gtCall.gtRetClsHnd;
structHnd = tree->AsCall()->GetLayout()->GetClassHandle();
break;
case GT_RET_EXPR:
structHnd = tree->AsRetExpr()->GetLayout()->GetClassHandle();
Expand Down
18 changes: 16 additions & 2 deletions src/jit/gentree.h
Original file line number Diff line number Diff line change
Expand Up @@ -3854,7 +3854,21 @@ struct GenTreeCall final : public GenTree
unsigned char gtCallType : 3; // value from the gtCallTypes enumeration
unsigned char gtReturnType : 5; // exact return type

CORINFO_CLASS_HANDLE gtRetClsHnd; // The return type handle of the call if it is a struct; always available
private:
ClassLayout* m_layout; // The return type handle of the call if it is a struct; always available

public:
ClassLayout* GetLayout() const
{
assert(varTypeIsStruct(TypeGet()));
return m_layout;
}

void SetLayout(ClassLayout* layout)
{
assert(varTypeIsStruct(TypeGet()) == (layout != nullptr));
m_layout = layout;
}

union {
// only used for CALLI unmanaged calls (CT_INDIRECT)
Expand Down Expand Up @@ -3905,7 +3919,7 @@ struct GenTreeCall final : public GenTree

bool AreArgsComplete() const;

GenTreeCall(var_types type) : GenTree(GT_CALL, type)
GenTreeCall(var_types type) : GenTree(GT_CALL, type), m_layout(nullptr)
{
fgArgInfo = nullptr;
}
Expand Down
9 changes: 5 additions & 4 deletions src/jit/importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1611,8 +1611,8 @@ GenTree* Compiler::impNormStructVal(GenTree* structVal,
break;

case GT_CALL:
structVal->gtCall.gtRetClsHnd = structHnd;
makeTemp = true;
structVal->AsCall()->SetLayout(typGetObjLayout(structHnd));
makeTemp = true;
break;

case GT_RET_EXPR:
Expand Down Expand Up @@ -8778,7 +8778,7 @@ GenTree* Compiler::impFixupCallStructReturn(GenTreeCall* call, CORINFO_CLASS_HAN
return call;
}

call->gtRetClsHnd = retClsHnd;
call->SetLayout(typGetObjLayout(retClsHnd));

#if FEATURE_MULTIREG_RET
// Initialize Return type descriptor of call node
Expand Down Expand Up @@ -18976,7 +18976,8 @@ void Compiler::impInlineInitVars(InlineInfo* pInlineInfo)
}

#ifdef FEATURE_SIMD
if (!foundSIMDType && (call->AsCall()->gtRetClsHnd != nullptr) && isSIMDorHWSIMDClass(call->AsCall()->gtRetClsHnd))
if (!foundSIMDType && varTypeIsStruct(call->AsCall()->TypeGet()) &&
isSIMDorHWSIMDClass(call->AsCall()->GetLayout()->GetClassHandle()))
{
foundSIMDType = true;
}
Expand Down
4 changes: 2 additions & 2 deletions src/jit/indirectcalltransformer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -620,9 +620,9 @@ class IndirectCallTransformer
returnTemp = compiler->lvaGrabTemp(false DEBUGARG("guarded devirt return temp"));
JITDUMP("Reworking call(s) to return value via a new temp V%02u\n", returnTemp);

if (varTypeIsStruct(origCall))
if (varTypeIsStruct(origCall->TypeGet()))
{
compiler->lvaSetStruct(returnTemp, origCall->gtRetClsHnd, false);
compiler->lvaSetStruct(returnTemp, origCall->GetLayout()->GetClassHandle(), false);
}

GenTree* tempTree = compiler->gtNewLclvNode(returnTemp, origCall->TypeGet());
Expand Down
8 changes: 4 additions & 4 deletions src/jit/morph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ GenTree* Compiler::fgMorphIntoHelperCall(GenTree* tree, int helper, GenTreeArgLi
{
// The helper call ought to be semantically equivalent to the original node, so preserve its VN.
tree->ChangeOper(GT_CALL, GenTree::PRESERVE_VN);
tree->AsCall()->SetLayout(nullptr);

tree->gtCall.gtCallType = CT_HELPER;
tree->gtCall.gtCallMethHnd = eeFindHelper(helper);
tree->gtCall.gtCallArgs = args;
tree->gtCall.gtCallObjp = nullptr;
tree->gtCall.gtCallLateArgs = nullptr;
tree->gtCall.fgArgInfo = nullptr;
tree->gtCall.gtRetClsHnd = nullptr;
tree->gtCall.gtCallMoreFlags = 0;
tree->gtCall.gtInlineCandidateInfo = nullptr;
tree->gtCall.gtControlExpr = nullptr;
Expand Down Expand Up @@ -5286,7 +5286,7 @@ void Compiler::fgFixupStructReturn(GenTree* callNode)

// Decide on the proper return type for this call that currently returns a struct
//
CORINFO_CLASS_HANDLE retClsHnd = call->gtRetClsHnd;
CORINFO_CLASS_HANDLE retClsHnd = call->GetLayout()->GetClassHandle();
Compiler::structPassingKind howToReturnStruct;
var_types returnType;

Expand Down Expand Up @@ -8340,7 +8340,7 @@ GenTree* Compiler::fgMorphCall(GenTreeCall* call)
GenTree* assg = nullptr;
if (varTypeIsStruct(callType))
{
CORINFO_CLASS_HANDLE structHandle = call->gtRetClsHnd;
CORINFO_CLASS_HANDLE structHandle = call->GetLayout()->GetClassHandle();
assert(structHandle != NO_CLASS_HANDLE);
const bool unsafeValueClsCheck = false;
lvaSetStruct(tmpNum, structHandle, unsafeValueClsCheck);
Expand Down Expand Up @@ -8697,7 +8697,7 @@ GenTree* Compiler::fgMorphCall(GenTreeCall* call)
// follows the old convention, and does whatever barrier is required.
if (call->gtCallType != CT_HELPER)
{
structHnd = call->gtRetClsHnd;
structHnd = call->GetLayout()->GetClassHandle();
if (info.compCompHnd->isStructRequiringStackAllocRetBuf(structHnd) &&
!(dest->OperGet() == GT_LCL_VAR && dest->gtLclVar.gtLclNum == info.compRetBuffArg))
{
Expand Down

0 comments on commit 867ab3f

Please sign in to comment.