[PATCH] D136927: [AMDGPU] Fix GCNDownwardRPTracker::advanceBeforeNext at the end of MBB
Valery Pykhtin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 1 14:55:56 PDT 2022
vpykhtin updated this revision to Diff 472412.
vpykhtin added a comment.
added assert !isDebugInstr
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D136927/new/
https://reviews.llvm.org/D136927
Files:
llvm/lib/Target/AMDGPU/GCNRegPressure.cpp
llvm/lib/Target/AMDGPU/GCNRegPressure.h
llvm/lib/Target/AMDGPU/GCNSchedStrategy.cpp
Index: llvm/lib/Target/AMDGPU/GCNSchedStrategy.cpp
===================================================================
--- llvm/lib/Target/AMDGPU/GCNSchedStrategy.cpp
+++ llvm/lib/Target/AMDGPU/GCNSchedStrategy.cpp
@@ -538,7 +538,6 @@
RPTracker.advanceToNext();
RPTracker.advance(MBB->end());
}
- RPTracker.reset(*OnlySucc->begin(), &RPTracker.getLiveRegs());
RPTracker.advanceBeforeNext();
MBBLiveIns[OnlySucc] = RPTracker.moveLiveRegs();
}
Index: llvm/lib/Target/AMDGPU/GCNRegPressure.h
===================================================================
--- llvm/lib/Target/AMDGPU/GCNRegPressure.h
+++ llvm/lib/Target/AMDGPU/GCNRegPressure.h
@@ -172,8 +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.
+ // Move to the state right before the next MI or after the end of MBB.
+ // Returns false if reached end of the block.
bool advanceBeforeNext();
// Move to the state at the MI, advanceBeforeNext has to be called first.
Index: llvm/lib/Target/AMDGPU/GCNRegPressure.cpp
===================================================================
--- llvm/lib/Target/AMDGPU/GCNRegPressure.cpp
+++ llvm/lib/Target/AMDGPU/GCNRegPressure.cpp
@@ -325,12 +325,14 @@
bool GCNDownwardRPTracker::advanceBeforeNext() {
assert(MRI && "call reset first");
+ if (!LastTrackedMI)
+ return NextMI == MBBEnd;
- NextMI = skipDebugInstructionsForward(NextMI, MBBEnd);
- if (NextMI == MBBEnd)
- return false;
+ assert(NextMI == MBBEnd || !NextMI->isDebugInstr());
- SlotIndex SI = LIS.getInstructionIndex(*NextMI).getBaseIndex();
+ SlotIndex SI = NextMI == MBBEnd
+ ? LIS.getInstructionIndex(*LastTrackedMI).getDeadSlot()
+ : LIS.getInstructionIndex(*NextMI).getBaseIndex();
assert(SI.isValid());
// Remove dead registers or mask bits.
@@ -355,7 +357,9 @@
MaxPressure = max(MaxPressure, CurPressure);
- return true;
+ LastTrackedMI = nullptr;
+
+ return NextMI == MBBEnd;
}
void GCNDownwardRPTracker::advanceToNext() {
@@ -379,9 +383,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;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136927.472412.patch
Type: text/x-patch
Size: 2520 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221101/0e60c183/attachment.bin>
More information about the llvm-commits
mailing list