From: Pat Gavlin Date: Fri, 21 Oct 2016 21:03:58 +0000 (-0700) Subject: Initialize long return type descs in `gtNewCallNode`. X-Git-Tag: submit/tizen/20210909.063632~11030^2~9113^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b2d2519cfb68a2e432782735a15bbe89ec003d4c;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Initialize long return type descs in `gtNewCallNode`. All long-returning calls (including helper calls) must have a properly initialized ReturnTypeDesc. Previously, this ReturnTypeDesc was only initialized by the importer for a subset of long-returning calls (essentially user calls), which caused asserts whenother long-returning calls were created by the compiler (e.g. for field accessors). This change moves the necessary ReturnTypeDesc initialization into `gtNewCallNode`. Commit migrated from https://github.com/dotnet/coreclr/commit/b2b0b914a68a9a74c8b8685851afb2f874246428 --- diff --git a/src/coreclr/src/jit/compiler.h b/src/coreclr/src/jit/compiler.h index a12d87b..62e3d37 100644 --- a/src/coreclr/src/jit/compiler.h +++ b/src/coreclr/src/jit/compiler.h @@ -2785,8 +2785,6 @@ protected: GenTreePtr impFixupCallStructReturn(GenTreePtr call, CORINFO_CLASS_HANDLE retClsHnd); - GenTreePtr impInitCallLongReturn(GenTreePtr call); - GenTreePtr impFixupStructReturnType(GenTreePtr op, CORINFO_CLASS_HANDLE retClsHnd); #ifdef DEBUG diff --git a/src/coreclr/src/jit/gentree.cpp b/src/coreclr/src/jit/gentree.cpp index f927978..b7e1c2e 100644 --- a/src/coreclr/src/jit/gentree.cpp +++ b/src/coreclr/src/jit/gentree.cpp @@ -6828,13 +6828,13 @@ GenTreeCall* Compiler::gtNewCallNode( #endif // LEGACY_BACKEND #ifdef FEATURE_READYTORUN_COMPILER - node->gtCall.gtEntryPoint.addr = nullptr; + node->gtEntryPoint.addr = nullptr; #endif #if defined(DEBUG) || defined(INLINE_DATA) // These get updated after call node is built. - node->gtCall.gtInlineObservation = InlineObservation::CALLEE_UNUSED_INITIAL; - node->gtCall.gtRawILOffset = BAD_IL_OFFSET; + node->gtInlineObservation = InlineObservation::CALLEE_UNUSED_INITIAL; + node->gtRawILOffset = BAD_IL_OFFSET; #endif // Spec: Managed Retval sequence points needs to be generated while generating debug info for debuggable code. @@ -6871,6 +6871,22 @@ GenTreeCall* Compiler::gtNewCallNode( // Initialize spill flags of gtOtherRegs node->ClearOtherRegFlags(); +#if defined(_TARGET_X86_) && !defined(LEGACY_BACKEND) + // Initialize the multi-reg long return info if necessary + if (varTypeIsLong(node)) + { + // The return type will remain as the incoming long type + 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); + } +#endif // defined(_TARGET_X86_) && !defined(_LEGACY_BACKEND_) + return node; } diff --git a/src/coreclr/src/jit/importer.cpp b/src/coreclr/src/jit/importer.cpp index 53e856c..3141fe2 100644 --- a/src/coreclr/src/jit/importer.cpp +++ b/src/coreclr/src/jit/importer.cpp @@ -7447,10 +7447,6 @@ DONE_CALL: { call = impFixupCallStructReturn(call, sig->retTypeClass); } - else if (varTypeIsLong(callRetTyp)) - { - call = impInitCallLongReturn(call); - } if ((call->gtFlags & GTF_CALL_INLINE_CANDIDATE) != 0) { @@ -7733,42 +7729,6 @@ GenTreePtr Compiler::impFixupCallStructReturn(GenTreePtr call, CORINFO_CLASS_HAN return call; } -//------------------------------------------------------------------------------------- -// impInitCallLongReturn: -// Initialize the ReturnTypDesc for a call that returns a TYP_LONG -// -// Arguments: -// call - GT_CALL GenTree node -// -// Return Value: -// Returns new GenTree node after initializing the ReturnTypeDesc of call node -// -GenTreePtr Compiler::impInitCallLongReturn(GenTreePtr call) -{ - assert(call->gtOper == GT_CALL); - -#if defined(_TARGET_X86_) && !defined(LEGACY_BACKEND) - // LEGACY_BACKEND does not use multi reg returns for calls with long return types - - if (varTypeIsLong(call)) - { - GenTreeCall* callNode = call->AsCall(); - - // The return type will remain as the incoming long type - callNode->gtReturnType = call->gtType; - - // Initialize Return type descriptor of call node - ReturnTypeDesc* retTypeDesc = callNode->GetReturnTypeDesc(); - retTypeDesc->InitializeLongReturnType(this); - - // must be a long returned in two registers - assert(retTypeDesc->GetReturnRegCount() == 2); - } -#endif // _TARGET_X86_ && !LEGACY_BACKEND - - return call; -} - /***************************************************************************** For struct return values, re-type the operand in the case where the ABI does not use a struct return buffer