Skip to content

Commit 28624f9

Browse files
committedJun 4, 2018
[AMDGPU] Factored out common part of GCNRPTracker::reset()
Differential Revision: https://reviews.llvm.org/D47664 llvm-svn: 333931
1 parent c418b5c commit 28624f9

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed
 

‎llvm/lib/Target/AMDGPU/GCNRegPressure.cpp

+14-11
Original file line numberDiff line numberDiff line change
@@ -284,18 +284,27 @@ GCNRPTracker::LiveRegSet llvm::getLiveRegs(SlotIndex SI,
284284
return LiveRegs;
285285
}
286286

287-
void GCNUpwardRPTracker::reset(const MachineInstr &MI,
288-
const LiveRegSet *LiveRegsCopy) {
289-
MRI = &MI.getParent()->getParent()->getRegInfo();
287+
void GCNRPTracker::reset(const MachineInstr &MI,
288+
const LiveRegSet *LiveRegsCopy,
289+
bool After) {
290+
const MachineFunction &MF = *MI.getMF();
291+
MRI = &MF.getRegInfo();
290292
if (LiveRegsCopy) {
291293
if (&LiveRegs != LiveRegsCopy)
292294
LiveRegs = *LiveRegsCopy;
293295
} else {
294-
LiveRegs = getLiveRegsAfter(MI, LIS);
296+
LiveRegs = After ? getLiveRegsAfter(MI, LIS)
297+
: getLiveRegsBefore(MI, LIS);
295298
}
299+
296300
MaxPressure = CurPressure = getRegPressure(*MRI, LiveRegs);
297301
}
298302

303+
void GCNUpwardRPTracker::reset(const MachineInstr &MI,
304+
const LiveRegSet *LiveRegsCopy) {
305+
GCNRPTracker::reset(MI, LiveRegsCopy, true);
306+
}
307+
299308
void GCNUpwardRPTracker::recede(const MachineInstr &MI) {
300309
assert(MRI && "call reset first");
301310

@@ -349,13 +358,7 @@ bool GCNDownwardRPTracker::reset(const MachineInstr &MI,
349358
NextMI = skipDebugInstructionsForward(NextMI, MBBEnd);
350359
if (NextMI == MBBEnd)
351360
return false;
352-
if (LiveRegsCopy) {
353-
if (&LiveRegs != LiveRegsCopy)
354-
LiveRegs = *LiveRegsCopy;
355-
} else {
356-
LiveRegs = getLiveRegsBefore(*NextMI, LIS);
357-
}
358-
MaxPressure = CurPressure = getRegPressure(*MRI, LiveRegs);
361+
GCNRPTracker::reset(*NextMI, LiveRegsCopy, false);
359362
return true;
360363
}
361364

‎llvm/lib/Target/AMDGPU/GCNRegPressure.h

+3
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ class GCNRPTracker {
106106

107107
GCNRPTracker(const LiveIntervals &LIS_) : LIS(LIS_) {}
108108

109+
void reset(const MachineInstr &MI, const LiveRegSet *LiveRegsCopy,
110+
bool After);
111+
109112
public:
110113
// live regs for the current state
111114
const decltype(LiveRegs) &getLiveRegs() const { return LiveRegs; }

0 commit comments

Comments
 (0)
Please sign in to comment.