Handle COMMA nodes when morphing struct args
authorCarol Eidt <carol.eidt@microsoft.com>
Wed, 1 Aug 2018 23:44:41 +0000 (16:44 -0700)
committerCarol Eidt <carol.eidt@microsoft.com>
Wed, 1 Aug 2018 23:44:41 +0000 (16:44 -0700)
Fix dotnet/coreclr#19124

Commit migrated from https://github.com/dotnet/coreclr/commit/3b17a68bf2825295a5f442ce9fc587930c0f07fa

src/coreclr/src/jit/morph.cpp

index 9b642c2..9465f4e 100644 (file)
@@ -4617,21 +4617,22 @@ GenTree* Compiler::fgMorphMultiregStructArg(GenTree* arg, fgArgTabEntry* fgEntry
 #endif
     {
         GenTreeLclVarCommon* lcl = nullptr;
+        GenTree* actualArg = arg->gtEffectiveVal();
 
-        if (arg->OperGet() == GT_OBJ)
+        if (actualArg->OperGet() == GT_OBJ)
         {
-            if (arg->gtGetOp1()->OperIs(GT_ADDR) && arg->gtGetOp1()->gtGetOp1()->OperIs(GT_LCL_VAR))
+            if (actualArg->gtGetOp1()->OperIs(GT_ADDR) && actualArg->gtGetOp1()->gtGetOp1()->OperIs(GT_LCL_VAR))
             {
-                lcl = arg->gtGetOp1()->gtGetOp1()->AsLclVarCommon();
+                lcl = actualArg->gtGetOp1()->gtGetOp1()->AsLclVarCommon();
             }
         }
         else
         {
-            assert(arg->OperGet() == GT_LCL_VAR);
+            assert(actualArg->OperGet() == GT_LCL_VAR);
 
             // We need to construct a `GT_OBJ` node for the argument,
             // so we need to get the address of the lclVar.
-            lcl = arg->AsLclVarCommon();
+            lcl = actualArg->AsLclVarCommon();
         }
         if (lcl != nullptr)
         {
@@ -4642,7 +4643,7 @@ GenTree* Compiler::fgMorphMultiregStructArg(GenTree* arg, fgArgTabEntry* fgEntry
             else if (arg->TypeGet() == TYP_STRUCT)
             {
                 // If this is a non-register struct, it must be referenced from memory.
-                if (!arg->OperIs(GT_OBJ))
+                if (!actualArg->OperIs(GT_OBJ))
                 {
                     // Create an Obj of the temp to use it as a call argument.
                     arg = gtNewOperNode(GT_ADDR, TYP_I_IMPL, arg);