Initialize long return type descs in `gtNewCallNode`.
authorPat Gavlin <pagavlin@microsoft.com>
Fri, 21 Oct 2016 21:03:58 +0000 (14:03 -0700)
committerPat Gavlin <pagavlin@microsoft.com>
Fri, 21 Oct 2016 21:03:58 +0000 (14:03 -0700)
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

src/coreclr/src/jit/compiler.h
src/coreclr/src/jit/gentree.cpp
src/coreclr/src/jit/importer.cpp

index a12d87b..62e3d37 100644 (file)
@@ -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
index f927978..b7e1c2e 100644 (file)
@@ -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;
 }
 
index 53e856c..3141fe2 100644 (file)
@@ -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