Skip to content

Commit b51270d

Browse files
authored
Fix majority of failures in libraries-jitstressregs after EHWriteThru enabled (#48829)
* Fix majority of libraries-jitstressregs When we verify final allocation, we were not resetting the `assignedInterval` if the interval got assigned to a different register. This was not consistent to what we do during allocation. Fixed following failures: https://dev.azure.com/dnceng/public/_build/results?buildId=989595&view=ms.vss-test-web.build-test-results-tab&runId=30998546&resultId=169282&paneView=dotnet-dnceng.dnceng-build-release-tasks.helix-test-information-tab https://helixre8s23ayyeko0k025g8.blob.core.windows.net/dotnet-runtime-refs-pull-47307-head-5f85fedec0cd4ff9a0/System.Net.Security.Tests/console.73e69194.log?sv=2019-07-07&se=2021-03-03T08%3A52%3A21Z&sr=c&sp=rl&sig=naQOrM%2BszKDyDAO8m%2BU%2Fu149f4cjodTk1dYCKl9cvKs%3D Failures happen on arch/OS - Linux arm64 - Linux arm - Linux x64 - Windows x86 - Windows x64 * Delete regsToFree and delayRegsToFree from verifyFinalAllocation These two variables were always set to `RBM_NONE`. As part of #48837, investigate how to reintroduce them. * jitformat
1 parent 146c865 commit b51270d

File tree

1 file changed

+12
-29
lines changed

1 file changed

+12
-29
lines changed

src/coreclr/jit/lsra.cpp

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -10755,8 +10755,6 @@ void LinearScan::verifyFinalAllocation()
1075510755

1075610756
BasicBlock* currentBlock = nullptr;
1075710757
GenTree* firstBlockEndResolutionNode = nullptr;
10758-
regMaskTP regsToFree = RBM_NONE;
10759-
regMaskTP delayRegsToFree = RBM_NONE;
1076010758
LsraLocation currentLocation = MinLocation;
1076110759
for (RefPosition& refPosition : refPositions)
1076210760
{
@@ -10766,12 +10764,7 @@ void LinearScan::verifyFinalAllocation()
1076610764
regNumber regNum = REG_NA;
1076710765
activeRefPosition = currentRefPosition;
1076810766

10769-
if (currentRefPosition->refType == RefTypeBB)
10770-
{
10771-
regsToFree |= delayRegsToFree;
10772-
delayRegsToFree = RBM_NONE;
10773-
}
10774-
else
10767+
if (currentRefPosition->refType != RefTypeBB)
1077510768
{
1077610769
if (currentRefPosition->IsPhysRegRef())
1077710770
{
@@ -10800,24 +10793,7 @@ void LinearScan::verifyFinalAllocation()
1080010793
}
1080110794

1080210795
LsraLocation newLocation = currentRefPosition->nodeLocation;
10803-
10804-
if (newLocation > currentLocation)
10805-
{
10806-
// Free Registers.
10807-
// We could use the freeRegisters() method, but we'd have to carefully manage the active intervals.
10808-
for (regNumber reg = REG_FIRST; reg < ACTUAL_REG_COUNT; reg = REG_NEXT(reg))
10809-
{
10810-
regMaskTP regMask = genRegMask(reg);
10811-
if ((regsToFree & regMask) != RBM_NONE)
10812-
{
10813-
RegRecord* physRegRecord = getRegisterRecord(reg);
10814-
physRegRecord->assignedInterval = nullptr;
10815-
}
10816-
}
10817-
regsToFree = delayRegsToFree;
10818-
regsToFree = RBM_NONE;
10819-
}
10820-
currentLocation = newLocation;
10796+
currentLocation = newLocation;
1082110797

1082210798
switch (currentRefPosition->refType)
1082310799
{
@@ -10984,6 +10960,7 @@ void LinearScan::verifyFinalAllocation()
1098410960
else if (RefTypeIsDef(currentRefPosition->refType))
1098510961
{
1098610962
interval->isActive = true;
10963+
1098710964
if (VERBOSE)
1098810965
{
1098910966
if (interval->isConstant && (currentRefPosition->treeNode != nullptr) &&
@@ -11055,11 +11032,17 @@ void LinearScan::verifyFinalAllocation()
1105511032
}
1105611033
else
1105711034
{
11058-
if (!currentRefPosition->copyReg)
11035+
if (RefTypeIsDef(currentRefPosition->refType))
1105911036
{
11060-
interval->physReg = regNum;
11061-
interval->assignedReg = regRecord;
11037+
// Interval was assigned to a different register.
11038+
// Clear the assigned interval of current register.
11039+
if (interval->physReg != REG_NA && interval->physReg != regNum)
11040+
{
11041+
interval->assignedReg->assignedInterval = nullptr;
11042+
}
1106211043
}
11044+
interval->physReg = regNum;
11045+
interval->assignedReg = regRecord;
1106311046
regRecord->assignedInterval = interval;
1106411047
}
1106511048
}

0 commit comments

Comments
 (0)