From acca0f5c02584702b0ee14ce747a565d9f157bd4 Mon Sep 17 00:00:00 2001 From: Stanislav Mekhanoshin Date: Tue, 16 May 2017 16:31:45 +0000 Subject: [PATCH] [AMDGPU] Use GCNRPTracker dumper methods in scheduler Differential Revision: https://reviews.llvm.org/D33244 llvm-svn: 303186 --- llvm/lib/Target/AMDGPU/GCNRegPressure.cpp | 12 ++++++++++++ llvm/lib/Target/AMDGPU/GCNRegPressure.h | 2 ++ llvm/lib/Target/AMDGPU/GCNSchedStrategy.cpp | 25 +++++++------------------ 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/llvm/lib/Target/AMDGPU/GCNRegPressure.cpp b/llvm/lib/Target/AMDGPU/GCNRegPressure.cpp index e2334f2..8066428 100644 --- a/llvm/lib/Target/AMDGPU/GCNRegPressure.cpp +++ b/llvm/lib/Target/AMDGPU/GCNRegPressure.cpp @@ -451,4 +451,16 @@ bool GCNUpwardRPTracker::isValid() const { return true; } +void GCNRPTracker::printLiveRegs(raw_ostream &OS, const LiveRegSet& LiveRegs, + const MachineRegisterInfo &MRI) { + const TargetRegisterInfo *TRI = MRI.getTargetRegisterInfo(); + for (unsigned I = 0, E = MRI.getNumVirtRegs(); I != E; ++I) { + unsigned Reg = TargetRegisterInfo::index2VirtReg(I); + auto It = LiveRegs.find(Reg); + if (It != LiveRegs.end() && It->second.any()) + OS << ' ' << PrintVRegOrUnit(Reg, TRI) << ':' + << PrintLaneMask(It->second); + } + OS << '\n'; +} #endif diff --git a/llvm/lib/Target/AMDGPU/GCNRegPressure.h b/llvm/lib/Target/AMDGPU/GCNRegPressure.h index 7b1974d..9875ca6 100644 --- a/llvm/lib/Target/AMDGPU/GCNRegPressure.h +++ b/llvm/lib/Target/AMDGPU/GCNRegPressure.h @@ -116,6 +116,8 @@ public: decltype(LiveRegs) moveLiveRegs() { return std::move(LiveRegs); } + static void printLiveRegs(raw_ostream &OS, const LiveRegSet& LiveRegs, + const MachineRegisterInfo &MRI); }; class GCNUpwardRPTracker : public GCNRPTracker { diff --git a/llvm/lib/Target/AMDGPU/GCNSchedStrategy.cpp b/llvm/lib/Target/AMDGPU/GCNSchedStrategy.cpp index c6d6022..8ec4666 100644 --- a/llvm/lib/Target/AMDGPU/GCNSchedStrategy.cpp +++ b/llvm/lib/Target/AMDGPU/GCNSchedStrategy.cpp @@ -337,21 +337,12 @@ void GCNScheduleDAGMILive::schedule() { if (LIS) { PressureBefore = Pressure[RegionIdx]; - DEBUG(const SIRegisterInfo *SRI = static_cast(TRI); - dbgs() << "Pressure before scheduling:\nRegion live-ins:"; - for (unsigned I = 0, E = MRI.getNumVirtRegs(); I != E; ++I) { - unsigned Reg = TargetRegisterInfo::index2VirtReg(I); - auto It = LiveIns[RegionIdx].find(Reg); - if (It != LiveIns[RegionIdx].end() && It->second.any()) - dbgs() << ' ' << PrintVRegOrUnit(Reg, SRI) << ':' - << PrintLaneMask(It->second); - } - auto P = llvm::getRegPressure(MRI, LiveIns[RegionIdx]); - dbgs() << "\nLive-in pressure:\nSGPR = " << P.getSGPRNum() - << "\nVGPR = " << P.getVGPRNum() - << "\nReal region's register pressure:\nSGPR = " - << PressureBefore.getSGPRNum() - << "\nVGPR = " << PressureBefore.getVGPRNum() << '\n'); + DEBUG(dbgs() << "Pressure before scheduling:\nRegion live-ins:"; + GCNRPTracker::printLiveRegs(dbgs(), LiveIns[RegionIdx], MRI); + dbgs() << "Region live-in pressure: "; + llvm::getRegPressure(MRI, LiveIns[RegionIdx]).print(dbgs()); + dbgs() << "Region register pressure: "; + PressureBefore.print(dbgs())); } ScheduleDAGMILive::schedule(); @@ -364,9 +355,7 @@ void GCNScheduleDAGMILive::schedule() { GCNMaxOccupancySchedStrategy &S = (GCNMaxOccupancySchedStrategy&)*SchedImpl; auto PressureAfter = getRealRegPressure(); - DEBUG(dbgs() << "Pressure after scheduling:\nSGPR = " - << PressureAfter.getSGPRNum() - << "\nVGPR = " << PressureAfter.getVGPRNum() << '\n'); + DEBUG(dbgs() << "Pressure after scheduling: "; PressureAfter.print(dbgs())); if (PressureAfter.getSGPRNum() <= S.SGPRCriticalLimit && PressureAfter.getVGPRNum() <= S.VGPRCriticalLimit) { -- 2.7.4