Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions src/coreclr/jit/lsra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11261,17 +11261,16 @@ void LinearScan::RegisterSelection::try_SPILL_COST()
}

float currentSpillWeight = 0;
RefPosition* recentRefPosition = spillCandidateRegRecord->assignedInterval != nullptr
? spillCandidateRegRecord->assignedInterval->recentRefPosition
: nullptr;
if ((recentRefPosition != nullptr) && (recentRefPosition->RegOptional() &&
!(spillCandidateRegRecord->assignedInterval->isLocalVar && recentRefPosition->IsActualRef())))
Interval* assignedInterval = spillCandidateRegRecord->assignedInterval;
RefPosition* recentRefPosition = (assignedInterval != nullptr) ? assignedInterval->recentRefPosition : nullptr;
if ((recentRefPosition != nullptr) &&
Copy link
Contributor

@kunalspathak kunalspathak Jul 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad for not spotting this formatting error in #55247. I also missed one more change to hoist spillCandidateRegRecord->assignedInterval. Do you mind changing that as well?

Interval* assignedInterval = spillCandidateRegRecord->assignedInterval;

// and then use assingedInterval at multiple places.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Contributor

@kunalspathak kunalspathak Jul 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might need to define it after the line:

RegRecord* spillCandidateRegRecord = &linearScan->physRegs[spillCandidateRegNum];
Interval*    assignedInterval      = spillCandidateRegRecord->assignedInterval;

so that you can use it in condition on line 11254 as well.

if ((linearScan->getNextIntervalRef(spillCandidateRegNum, regType) == currentLocation) &&
            !assignedInterval->getNextRefPosition()->RegOptional())
        {
            continue;
        }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please open a PR with a fix? I think it would be faster and less confusing for the history/blame.

(recentRefPosition->RegOptional() && !(assignedInterval->isLocalVar && recentRefPosition->IsActualRef())))
{
// We do not "spillAfter" if previous (recent) refPosition was regOptional or if it
// is not an actual ref. In those cases, we will reload in future (next) refPosition.
// For such cases, consider the spill cost of next refposition.
// See notes in "spillInterval()".
RefPosition* reloadRefPosition = spillCandidateRegRecord->assignedInterval->getNextRefPosition();
RefPosition* reloadRefPosition = assignedInterval->getNextRefPosition();
if (reloadRefPosition != nullptr)
{
currentSpillWeight = linearScan->getWeight(reloadRefPosition);
Expand Down