move fgFixupStructReturn (#14966)
authorSergey Andreenko <seandree@microsoft.com>
Wed, 15 Nov 2017 00:30:52 +0000 (16:30 -0800)
committerGitHub <noreply@github.com>
Wed, 15 Nov 2017 00:30:52 +0000 (16:30 -0800)
It was done twice during the tail call optimization and in the args morphing. The problem is if tail call optimization was aborted it was not clear was `fgFixupStructReturn` called or not.

src/jit/morph.cpp

index 80a0008..cb31f47 100644 (file)
@@ -3065,11 +3065,6 @@ GenTreeCall* Compiler::fgMorphArgs(GenTreeCall* call)
         call->fgArgInfo = new (this, CMK_Unknown) fgArgInfo(this, call, numArgs);
     }
 
-    if (varTypeIsStruct(call))
-    {
-        fgFixupStructReturn(call);
-    }
-
     /* First we morph the argument subtrees ('this' pointer, arguments, etc.).
      * During the first call to fgMorphArgs we also record the
      * information about late arguments we have in 'fgArgInfo'.
@@ -8253,6 +8248,10 @@ GenTreePtr Compiler::fgAssignRecursiveCallArgToCallerParam(GenTreePtr       arg,
 
 GenTreePtr Compiler::fgMorphCall(GenTreeCall* call)
 {
+    if (varTypeIsStruct(call))
+    {
+        fgFixupStructReturn(call);
+    }
     if (call->CanTailCall())
     {
         // It should either be an explicit (i.e. tail prefixed) or an implicit tail call
@@ -8397,11 +8396,6 @@ GenTreePtr Compiler::fgMorphCall(GenTreeCall* call)
         }
 #endif // FEATURE_TAILCALL_OPT
 
-        if (varTypeIsStruct(call))
-        {
-            fgFixupStructReturn(call);
-        }
-
         var_types callType = call->TypeGet();
 
         // We have to ensure to pass the incoming retValBuf as the