diff --git a/llvm/lib/Target/AMDGPU/GCNRegPressure.h b/llvm/lib/Target/AMDGPU/GCNRegPressure.h --- a/llvm/lib/Target/AMDGPU/GCNRegPressure.h +++ b/llvm/lib/Target/AMDGPU/GCNRegPressure.h @@ -172,9 +172,8 @@ // Returns false if block is empty except debug values. bool reset(const MachineInstr &MI, const LiveRegSet *LiveRegs = nullptr); - // Move to the state right before the next MI. Returns false if reached - // end of the block. - bool advanceBeforeNext(); + // Move to the state right before the next MI or after the end of MBB + void advanceBeforeNext(); // Move to the state at the MI, advanceBeforeNext has to be called first. void advanceToNext(); diff --git a/llvm/lib/Target/AMDGPU/GCNRegPressure.cpp b/llvm/lib/Target/AMDGPU/GCNRegPressure.cpp --- a/llvm/lib/Target/AMDGPU/GCNRegPressure.cpp +++ b/llvm/lib/Target/AMDGPU/GCNRegPressure.cpp @@ -339,14 +339,12 @@ return true; } -bool GCNDownwardRPTracker::advanceBeforeNext() { +void GCNDownwardRPTracker::advanceBeforeNext() { assert(MRI && "call reset first"); + if (!LastTrackedMI) + return; - NextMI = skipDebugInstructionsForward(NextMI, MBBEnd); - if (NextMI == MBBEnd) - return false; - - SlotIndex SI = LIS.getInstructionIndex(*NextMI).getBaseIndex(); + SlotIndex SI = LIS.getInstructionIndex(*LastTrackedMI).getDeadSlot(); assert(SI.isValid()); // Remove dead registers or mask bits. @@ -371,7 +369,7 @@ MaxPressure = max(MaxPressure, CurPressure); - return true; + LastTrackedMI = nullptr; } void GCNDownwardRPTracker::advanceToNext() { @@ -396,8 +394,9 @@ bool GCNDownwardRPTracker::advance() { // If we have just called reset live set is actual. - if ((NextMI == MBBEnd) || (LastTrackedMI && !advanceBeforeNext())) + if (NextMI == MBBEnd) return false; + advanceBeforeNext(); advanceToNext(); return true; } diff --git a/llvm/lib/Target/AMDGPU/GCNSchedStrategy.cpp b/llvm/lib/Target/AMDGPU/GCNSchedStrategy.cpp --- a/llvm/lib/Target/AMDGPU/GCNSchedStrategy.cpp +++ b/llvm/lib/Target/AMDGPU/GCNSchedStrategy.cpp @@ -541,7 +541,6 @@ RPTracker.advanceToNext(); RPTracker.advance(MBB->end()); } - RPTracker.reset(*OnlySucc->begin(), &RPTracker.getLiveRegs()); RPTracker.advanceBeforeNext(); MBBLiveIns[OnlySucc] = RPTracker.moveLiveRegs(); }