Reset assignedInterval during verifyFinalAllocation (#49286)
authorKunal Pathak <Kunal.Pathak@microsoft.com>
Tue, 9 Mar 2021 17:00:42 +0000 (09:00 -0800)
committerGitHub <noreply@github.com>
Tue, 9 Mar 2021 17:00:42 +0000 (09:00 -0800)
* Unassign register for RefTypeDef if it is not assigned register

Fix failures exposed by EHWriteThru:

https://dev.azure.com/dnceng/public/_build/results?buildId=1021926&view=ms.vss-test-web.build-test-results-tab&runId=31791570&resultId=180705&paneView=dotnet-dnceng.dnceng-build-release-tasks.helix-test-information-tab

https://helixre8s23ayyeko0k025g8.blob.core.windows.net/dotnet-runtime-refs-pull-47307-head-ad03bd78ebf7456dbe/System.Memory.Tests/console.387c2cf0.log?sv=2019-07-07&se=2021-03-24T01%3A36%3A31Z&sr=c&sp=rl&sig=hPD%2B625ykQtQRVKnl3pCZzTEiI5hXzrqZtIPgo6Wc74%3D

* Fix more asserts for spillAfter/Def where assignedInterval was not reset

Fixes errors like this:

https://dev.azure.com/dnceng/public/_build/results?buildId=1024357&view=ms.vss-test-web.build-test-results-tab&runId=31848698&resultId=181011&paneView=dotnet-dnceng.dnceng-build-release-tasks.helix-test-information-tab

https://helixre8s23ayyeko0k025g8.blob.core.windows.net/dotnet-runtime-refs-pull-47307-head-2f177492e7644d448d/System.Management.Tests/console.5337e574.log?sv=2019-07-07&se=2021-03-25T09%3A27%3A01Z&sr=c&sp=rl&sig=aBfB4tstmjMyucEadkhaFxtWdog3teT32PvzPAS4Vv4%3D

* jit format

src/coreclr/jit/lsra.cpp
src/coreclr/jit/lsra.h

index 31127e8..2fb9556 100644 (file)
@@ -10955,6 +10955,22 @@ void LinearScan::verifyFinalAllocation()
                 }
                 if (regNum == REG_NA)
                 {
+                    // If this interval is still assigned to a register
+                    if (interval->physReg != REG_NA)
+                    {
+                        // then unassign it if no new register was assigned to the RefTypeDef
+                        if (RefTypeIsDef(currentRefPosition->refType))
+                        {
+                            assert(interval->assignedReg != nullptr);
+                            if (interval->assignedReg->assignedInterval == interval)
+                            {
+                                interval->assignedReg->assignedInterval = nullptr;
+                            }
+                            interval->physReg     = REG_NA;
+                            interval->assignedReg = nullptr;
+                        }
+                    }
+
                     dumpLsraAllocationEvent(LSRA_EVENT_NO_REG_ALLOCATED, interval);
                 }
                 else if (RefTypeIsDef(currentRefPosition->refType))
@@ -11093,6 +11109,16 @@ void LinearScan::verifyFinalAllocation()
                 {
                     assert(!currentRefPosition->spillAfter || currentRefPosition->IsActualRef());
 
+                    if (RefTypeIsDef(currentRefPosition->refType))
+                    {
+                        // If an interval got assigned to a different register (while the different
+                        // register got spilled), then clear the assigned interval of current register.
+                        if (interval->physReg != REG_NA && interval->physReg != regNum)
+                        {
+                            interval->assignedReg->assignedInterval = nullptr;
+                        }
+                    }
+
                     interval->physReg     = REG_NA;
                     interval->assignedReg = nullptr;
 
index 345cbb4..f381e22 100644 (file)
@@ -510,9 +510,6 @@ public:
     void tinyDump();
 #endif // DEBUG
 
-    // RefPosition   * getNextRefPosition();
-    // LsraLocation    getNextRefLocation();
-
     // DATA
 
     // interval to which this register is currently allocated.