Update var life for multireg local
authorCarol Eidt <carol.eidt@microsoft.com>
Thu, 13 Dec 2018 23:46:40 +0000 (15:46 -0800)
committerCarol Eidt <carol.eidt@microsoft.com>
Thu, 13 Dec 2018 23:51:23 +0000 (15:51 -0800)
When a multi-reg var is defined by a call, but doesn't currently reside in a register,
we must still update liveness.

Fix dotnet/coreclr#21500

Commit migrated from https://github.com/dotnet/coreclr/commit/61bdd1c239ce0f0c575b3ecc62e2c29ce9e27ede

src/coreclr/src/jit/codegenarmarch.cpp
src/coreclr/src/jit/codegenlinear.cpp

index 9b61328..494234b 100644 (file)
@@ -1296,6 +1296,7 @@ void CodeGen::genMultiRegCallStoreToLocal(GenTree* treeNode)
             offset += genTypeSize(type);
         }
 
+        genUpdateLife(treeNode);
         varDsc->lvRegNum = REG_STK;
     }
 }
index f474b88..3d4fe1a 100644 (file)
@@ -512,15 +512,30 @@ void CodeGen::genCodeForBBlist()
         // it up to date for vars that are not register candidates
         // (it would be nice to have a xor set function)
 
-        VARSET_TP extraLiveVars(VarSetOps::Diff(compiler, block->bbLiveOut, compiler->compCurLife));
-        VarSetOps::UnionD(compiler, extraLiveVars, VarSetOps::Diff(compiler, compiler->compCurLife, block->bbLiveOut));
-        VarSetOps::Iter extraLiveVarIter(compiler, extraLiveVars);
-        unsigned        extraLiveVarIndex = 0;
-        while (extraLiveVarIter.NextElem(&extraLiveVarIndex))
-        {
-            unsigned   varNum = compiler->lvaTrackedToVarNum[extraLiveVarIndex];
+        VARSET_TP mismatchLiveVars(VarSetOps::Diff(compiler, block->bbLiveOut, compiler->compCurLife));
+        VarSetOps::UnionD(compiler, mismatchLiveVars,
+                          VarSetOps::Diff(compiler, compiler->compCurLife, block->bbLiveOut));
+        VarSetOps::Iter mismatchLiveVarIter(compiler, mismatchLiveVars);
+        unsigned        mismatchLiveVarIndex  = 0;
+        bool            foundMismatchedRegVar = false;
+        while (mismatchLiveVarIter.NextElem(&mismatchLiveVarIndex))
+        {
+            unsigned   varNum = compiler->lvaTrackedToVarNum[mismatchLiveVarIndex];
             LclVarDsc* varDsc = compiler->lvaTable + varNum;
-            assert(!varDsc->lvIsRegCandidate());
+            if (varDsc->lvIsRegCandidate())
+            {
+                if (!foundMismatchedRegVar)
+                {
+                    JITDUMP("Mismatched live reg vars after BB%02u:", block->bbNum);
+                    foundMismatchedRegVar = true;
+                }
+                JITDUMP(" V%02u", varNum);
+            }
+        }
+        if (foundMismatchedRegVar)
+        {
+            assert(!"Found mismatched live reg var(s) after block");
+            JITDUMP("\n");
         }
 #endif