Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Replace non-const GetReturnTypeDesc with other methods.
  • Loading branch information
Sergey Andreenko committed May 15, 2020
commit 82ee49431649bcbd3088c7509a2b89c2b78fbe3b
2 changes: 1 addition & 1 deletion src/coreclr/src/jit/codegencommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11554,7 +11554,7 @@ void CodeGen::genReturn(GenTree* treeNode)
{
if (varTypeIsLong(compiler->info.compRetNativeType))
{
retTypeDesc.InitializeLongReturnType(compiler);
retTypeDesc.InitializeLongReturnType();
}
else // we must have a struct return type
{
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/src/jit/codegenxarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ void CodeGen::genEmitGSCookieCheck(bool pushReg)
ReturnTypeDesc retTypeDesc;
if (varTypeIsLong(compiler->info.compRetNativeType))
{
retTypeDesc.InitializeLongReturnType(compiler);
retTypeDesc.InitializeLongReturnType();
}
else // we must have a struct return type
{
Expand Down
8 changes: 2 additions & 6 deletions src/coreclr/src/jit/decomposelongs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1362,19 +1362,15 @@ GenTree* DecomposeLongs::DecomposeShift(LIR::Use& use)

GenTreeCall::Use* argList = m_compiler->gtNewCallArgs(loOp1, hiOp1, shiftByOp);

GenTree* call = m_compiler->gtNewHelperCallNode(helper, TYP_LONG, argList);
GenTreeCall* call = m_compiler->gtNewHelperCallNode(helper, TYP_LONG, argList);
call->gtFlags |= shift->gtFlags & GTF_ALL_EFFECT;

if (shift->IsUnusedValue())
{
call->SetUnusedValue();
}

GenTreeCall* callNode = call->AsCall();
ReturnTypeDesc* retTypeDesc = callNode->GetReturnTypeDesc();
retTypeDesc->InitializeLongReturnType(m_compiler);

call = m_compiler->fgMorphArgs(callNode);
call = m_compiler->fgMorphArgs(call);
Range().InsertAfter(shift, LIR::SeqTree(m_compiler, call));

Range().Remove(shift);
Expand Down
31 changes: 8 additions & 23 deletions src/coreclr/src/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ bool GenTree::gtHasReg() const
{
const GenTreeCopyOrReload* copyOrReload = AsCopyOrReload();
const GenTreeCall* call = copyOrReload->gtGetOp1()->AsCall();
unsigned regCount = call->GetReturnTypeDesc()->GetReturnRegCount();
const unsigned regCount = call->GetReturnTypeDesc()->GetReturnRegCount();

// A Multi-reg copy or reload node is said to have regs,
// if it has valid regs in any of the positions.
Expand Down Expand Up @@ -6172,21 +6172,14 @@ GenTreeCall* Compiler::gtNewCallNode(
// Initialize spill flags of gtOtherRegs
node->ClearOtherRegFlags();

#if defined(TARGET_X86) || defined(TARGET_ARM)
// Initialize the multi-reg long return info if necessary
#if !defined(TARGET_64BIT)
if (varTypeIsLong(node))
{
// The return type will remain as the incoming long type
node->gtReturnType = node->gtType;

assert(node->gtReturnType == node->gtType);
// Initialize Return type descriptor of call node
ReturnTypeDesc* retTypeDesc = node->GetReturnTypeDesc();
retTypeDesc->InitializeLongReturnType(this);

// must be a long returned in two registers
assert(retTypeDesc->GetReturnRegCount() == 2);
node->InitializeLongReturnType();
}
#endif // defined(TARGET_X86) || defined(TARGET_ARM)
#endif // !defined(TARGET_64BIT)

return node;
}
Expand Down Expand Up @@ -15305,9 +15298,7 @@ GenTree* Compiler::gtNewRefCOMfield(GenTree* objPtr,
#if FEATURE_MULTIREG_RET
if (varTypeIsStruct(call))
{
// Initialize Return type descriptor of call node.
ReturnTypeDesc* retTypeDesc = call->GetReturnTypeDesc();
retTypeDesc->InitializeStructReturnType(this, structType);
call->InitializeStructReturnType(this, structType);
}
#endif // FEATURE_MULTIREG_RET

Expand Down Expand Up @@ -18899,16 +18890,10 @@ void ReturnTypeDesc::InitializeStructReturnType(Compiler* comp, CORINFO_CLASS_HA
// InitializeLongReturnType:
// Initialize the Return Type Descriptor for a method that returns a TYP_LONG
//
// Arguments
// comp - Compiler Instance
//
// Return Value
// None
//
void ReturnTypeDesc::InitializeLongReturnType(Compiler* comp)
void ReturnTypeDesc::InitializeLongReturnType()
{
assert(!m_inited);
#if defined(TARGET_X86) || defined(TARGET_ARM)

// Setups up a ReturnTypeDesc for returning a long using two registers
//
assert(MAX_RET_REG_COUNT >= 2);
Expand Down
34 changes: 18 additions & 16 deletions src/coreclr/src/jit/gentree.h
Original file line number Diff line number Diff line change
Expand Up @@ -3600,8 +3600,8 @@ struct ReturnTypeDesc
void InitializeStructReturnType(Compiler* comp, CORINFO_CLASS_HANDLE retClsHnd);

// Initialize the Return Type Descriptor for a method that returns a TYP_LONG
// Only needed for X86
void InitializeLongReturnType(Compiler* comp);
// Only needed for X86 and arm32.
void InitializeLongReturnType();

// Reset type descriptor to defaults
void Reset()
Expand Down Expand Up @@ -3950,22 +3950,24 @@ struct GenTreeCall final : public GenTree
#endif
}

//-----------------------------------------------------------------------
// GetReturnTypeDesc: get the type descriptor of return value of the call
//
// Arguments:
// None
//
// Returns
// Type descriptor of the value returned by call
//
// TODO-AllArch: enable for all call nodes to unify single-reg and multi-reg returns.
ReturnTypeDesc* GetReturnTypeDesc()
void InitializeLongReturnType()
{
#if FEATURE_MULTIREG_RET
return &gtReturnTypeDesc;
#else
return nullptr;
gtReturnTypeDesc.InitializeLongReturnType();
#endif
}

void InitializeStructReturnType(Compiler* comp, CORINFO_CLASS_HANDLE retClsHnd)
{
#if FEATURE_MULTIREG_RET
gtReturnTypeDesc.InitializeStructReturnType(comp, retClsHnd);
#endif
}

void ResetReturnType()
{
#if FEATURE_MULTIREG_RET
gtReturnTypeDesc.Reset();
#endif
}

Expand Down
9 changes: 4 additions & 5 deletions src/coreclr/src/jit/importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8888,17 +8888,16 @@ GenTree* Compiler::impFixupCallStructReturn(GenTreeCall* call, CORINFO_CLASS_HAN
call->gtRetClsHnd = retClsHnd;

#if FEATURE_MULTIREG_RET
// Initialize Return type descriptor of call node
ReturnTypeDesc* retTypeDesc = call->GetReturnTypeDesc();
retTypeDesc->InitializeStructReturnType(this, retClsHnd);
call->InitializeStructReturnType(this, retClsHnd);
#endif // FEATURE_MULTIREG_RET

#ifdef UNIX_AMD64_ABI

// Not allowed for FEATURE_CORCLR which is the only SKU available for System V OSs.
assert(!call->IsVarargs() && "varargs not allowed for System V OSs.");

unsigned retRegCount = retTypeDesc->GetReturnRegCount();
const ReturnTypeDesc* retTypeDesc = call->GetReturnTypeDesc();
const unsigned retRegCount = retTypeDesc->GetReturnRegCount();
if (retRegCount == 0)
{
// struct not returned in registers i.e returned via hiddden retbuf arg.
Expand Down Expand Up @@ -9002,7 +9001,7 @@ GenTree* Compiler::impFixupCallStructReturn(GenTreeCall* call, CORINFO_CLASS_HAN
}

#if FEATURE_MULTIREG_RET
unsigned retRegCount = retTypeDesc->GetReturnRegCount();
const unsigned retRegCount = call->GetReturnTypeDesc()->GetReturnRegCount();
assert(retRegCount != 0);

if (retRegCount >= 2)
Expand Down
18 changes: 14 additions & 4 deletions src/coreclr/src/jit/morph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,23 @@ GenTree* Compiler::fgMorphIntoHelperCall(GenTree* tree, int helper, GenTreeCall:
#ifndef TARGET_64BIT
if (varTypeIsLong(tree))
{
GenTreeCall* callNode = tree->AsCall();
ReturnTypeDesc* retTypeDesc = callNode->GetReturnTypeDesc();
retTypeDesc->Reset();
retTypeDesc->InitializeLongReturnType(this);
GenTreeCall* callNode = tree->AsCall();
callNode->ResetReturnType();
callNode->InitializeLongReturnType();
callNode->ClearOtherRegs();
// TODO: we leave garbage here, call `ClearOtherRegFlags`.
// assert(callNode->gtSpillFlags == 0);
}
else
#endif // !TARGET_64BIT
{
// TODO: we leave garbage here in gtSpillFlags, gtOtherRegs and gtReturnTypeDesc.
// However, we probably never create a helper that returns struct type
// so we never read it.
// GenTreeCall* callNode = tree->AsCall();
// assert(callNode->gtOtherRegs[0] == 0);
// assert(callNode->gtOtherRegs[1] == 0);
}

if (tree->OperMayThrow(this))
{
Expand Down