[AMDGPU] Factored out common part of GCNRPTracker::reset()
Differential Revision: https://reviews.llvm.org/D47664
llvm-svn: 333931
diff --git a/llvm/lib/Target/AMDGPU/GCNRegPressure.cpp b/llvm/lib/Target/AMDGPU/GCNRegPressure.cpp
index 4e569a2..53b552a 100644
--- a/llvm/lib/Target/AMDGPU/GCNRegPressure.cpp
+++ b/llvm/lib/Target/AMDGPU/GCNRegPressure.cpp
@@ -284,18 +284,27 @@
return LiveRegs;
}
-void GCNUpwardRPTracker::reset(const MachineInstr &MI,
- const LiveRegSet *LiveRegsCopy) {
- MRI = &MI.getParent()->getParent()->getRegInfo();
+void GCNRPTracker::reset(const MachineInstr &MI,
+ const LiveRegSet *LiveRegsCopy,
+ bool After) {
+ const MachineFunction &MF = *MI.getMF();
+ MRI = &MF.getRegInfo();
if (LiveRegsCopy) {
if (&LiveRegs != LiveRegsCopy)
LiveRegs = *LiveRegsCopy;
} else {
- LiveRegs = getLiveRegsAfter(MI, LIS);
+ LiveRegs = After ? getLiveRegsAfter(MI, LIS)
+ : getLiveRegsBefore(MI, LIS);
}
+
MaxPressure = CurPressure = getRegPressure(*MRI, LiveRegs);
}
+void GCNUpwardRPTracker::reset(const MachineInstr &MI,
+ const LiveRegSet *LiveRegsCopy) {
+ GCNRPTracker::reset(MI, LiveRegsCopy, true);
+}
+
void GCNUpwardRPTracker::recede(const MachineInstr &MI) {
assert(MRI && "call reset first");
@@ -349,13 +358,7 @@
NextMI = skipDebugInstructionsForward(NextMI, MBBEnd);
if (NextMI == MBBEnd)
return false;
- if (LiveRegsCopy) {
- if (&LiveRegs != LiveRegsCopy)
- LiveRegs = *LiveRegsCopy;
- } else {
- LiveRegs = getLiveRegsBefore(*NextMI, LIS);
- }
- MaxPressure = CurPressure = getRegPressure(*MRI, LiveRegs);
+ GCNRPTracker::reset(*NextMI, LiveRegsCopy, false);
return true;
}