1212//
1313// ===----------------------------------------------------------------------===//
1414
15+ #include " AMDGPU.h"
1516#include " AMDGPUMIRUtils.h"
1617#include " AMDGPUOccupancyAndLatencyHelper.h"
17- #include " AMDGPU.h"
18+ #include " GCNRegPressure.h"
19+ #include " SIInstrInfo.h"
20+ #include " SIMachineFunctionInfo.h"
21+ #include " SIRegisterInfo.h"
22+ #include " llvm/ADT/MapVector.h"
1823#include " llvm/CodeGen/LiveInterval.h"
1924#include " llvm/CodeGen/LiveIntervals.h"
2025#include " llvm/CodeGen/MachineDominators.h"
2126#include " llvm/CodeGen/MachineLoopInfo.h"
2227#include " llvm/CodeGen/MachinePostDominators.h"
23- #include " llvm/ADT/MapVector.h"
2428#include " llvm/CodeGen/SlotIndexes.h"
25- #include " SIInstrInfo.h"
26- #include " SIMachineFunctionInfo.h"
27- #include " SIRegisterInfo.h"
28- #include " GCNRegPressure.h"
2929
3030#define DEBUG_TYPE " amdgpu-hot-block-remat"
3131
@@ -111,19 +111,18 @@ class AMDGPUHotBlockRematerialize : public MachineFunctionPass {
111111
112112 bool runOnMachineFunction (MachineFunction &MF) override ;
113113
114- void applyCloneRemat (RematNode &Node,
115- std::vector<BlockLiveInfo> &HotBlocks,
116- MachineDominatorTree *DT, MachineRegisterInfo &MRI,
117- SlotIndexes *SlotIndexes, const SIRegisterInfo *SIRI,
118- const SIInstrInfo *SIII, MachineFunction &MF);
114+ void applyCloneRemat (RematNode &Node, std::vector<BlockLiveInfo> &HotBlocks,
115+ MachineDominatorTree *DT, MachineRegisterInfo &MRI,
116+ SlotIndexes *SlotIndexes, const SIRegisterInfo *SIRI,
117+ const SIInstrInfo *SIII, MachineFunction &MF);
119118 void applyRemat (MapVector<Register, RematNode> &RematMap,
120- std::vector<BlockLiveInfo> &HotBlocks, MachineDominatorTree *DT ,
121- llvm::SlotIndexes *SlotIndexes, MachineRegisterInfo &MRI ,
122- const SIRegisterInfo *SIRI , const SIInstrInfo *SIII ,
123- MachineFunction &MF);
119+ std::vector<BlockLiveInfo> &HotBlocks,
120+ MachineDominatorTree *DT, llvm::SlotIndexes *SlotIndexes,
121+ MachineRegisterInfo &MRI , const SIRegisterInfo *SIRI ,
122+ const SIInstrInfo *SIII, MachineFunction &MF);
124123 bool hotBlockRemat (MachineFunction &MF, MachineLoopInfo *MLI,
125- LiveIntervals *LIS, MachineDominatorTree *DT,
126- MachinePostDominatorTree *PDT, bool &IsNearTarget);
124+ LiveIntervals *LIS, MachineDominatorTree *DT,
125+ MachinePostDominatorTree *PDT, bool &IsNearTarget);
127126
128127 StringRef getPassName () const override { return " AMDGPU rematerialize" ; }
129128
@@ -237,11 +236,11 @@ void updateUsers(unsigned Reg, unsigned NewReg, bool IsSubRegDef,
237236 }
238237}
239238
240- void AMDGPUHotBlockRematerialize::applyCloneRemat (RematNode &Node,
241- std::vector<BlockLiveInfo> &HotBlocks,
242- MachineDominatorTree *DT, MachineRegisterInfo &MRI,
243- SlotIndexes *SlotIndexes, const SIRegisterInfo *SIRI,
244- const SIInstrInfo *SIII, MachineFunction &MF) {
239+ void AMDGPUHotBlockRematerialize::applyCloneRemat (
240+ RematNode &Node, std::vector<BlockLiveInfo> &HotBlocks,
241+ MachineDominatorTree *DT, MachineRegisterInfo &MRI,
242+ SlotIndexes *SlotIndexes, const SIRegisterInfo *SIRI,
243+ const SIInstrInfo *SIII, MachineFunction &MF) {
245244 unsigned Reg = Node.Reg ;
246245
247246 MachineInstr *DefMI = MRI.getUniqueVRegDef (Reg);
@@ -359,11 +358,11 @@ void applyOneDefOneUseRemat(RematNode &Node, MachineRegisterInfo &MRI,
359358 SlotIndexes->insertMachineInstrInMaps (*DefMI);
360359}
361360
362- void AMDGPUHotBlockRematerialize::applyRemat (MapVector<Register, RematNode> &RematMap,
363- std::vector<BlockLiveInfo> &HotBlocks, MachineDominatorTree *DT ,
364- llvm::SlotIndexes *SlotIndexes, MachineRegisterInfo &MRI ,
365- const SIRegisterInfo *SIRI, const SIInstrInfo *SIII ,
366- MachineFunction &MF) {
361+ void AMDGPUHotBlockRematerialize::applyRemat (
362+ MapVector<Register, RematNode> &RematMap ,
363+ std::vector<BlockLiveInfo> &HotBlocks, MachineDominatorTree *DT ,
364+ llvm::SlotIndexes *SlotIndexes, MachineRegisterInfo &MRI ,
365+ const SIRegisterInfo *SIRI, const SIInstrInfo *SIII, MachineFunction &MF) {
367366 std::vector<RematNode> UpdateList;
368367 for (auto &It : RematMap) {
369368 UpdateList.emplace_back (It.second );
@@ -381,8 +380,7 @@ void AMDGPUHotBlockRematerialize::applyRemat(MapVector<Register, RematNode> &Rem
381380 if (Node.Kind == RematNode::RematKind::OneDefOneUse) {
382381 applyOneDefOneUseRemat (Node, MRI, SlotIndexes, SIRI, SIII);
383382 } else if (Node.Kind == RematNode::RematKind::Clone) {
384- applyCloneRemat (Node, HotBlocks, DT, MRI, SlotIndexes, SIRI, SIII,
385- MF);
383+ applyCloneRemat (Node, HotBlocks, DT, MRI, SlotIndexes, SIRI, SIII, MF);
386384 }
387385 }
388386}
@@ -1234,9 +1232,12 @@ void dumpCandidates(std::vector<RematNode> &RematCandidates, int BlockIndex,
12341232 dbgs () << " Total Size:" << TotalSize << " \n " ;
12351233}
12361234
1237- bool AMDGPUHotBlockRematerialize::hotBlockRemat (MachineFunction &MF, MachineLoopInfo *MLI,
1238- LiveIntervals *LIS, MachineDominatorTree *DT,
1239- MachinePostDominatorTree *PDT, bool &IsNearTarget) {
1235+ bool AMDGPUHotBlockRematerialize::hotBlockRemat (MachineFunction &MF,
1236+ MachineLoopInfo *MLI,
1237+ LiveIntervals *LIS,
1238+ MachineDominatorTree *DT,
1239+ MachinePostDominatorTree *PDT,
1240+ bool &IsNearTarget) {
12401241 const GCNSubtarget *ST = &MF.getSubtarget <GCNSubtarget>();
12411242
12421243 const SIInstrInfo *SIII = ST->getInstrInfo ();
@@ -1489,8 +1490,7 @@ bool AMDGPUHotBlockRematerialize::hotBlockRemat(MachineFunction &MF, MachineLoop
14891490
14901491 if (!SRematMap.empty ()) {
14911492 IsUpdated = true ;
1492- applyRemat (SRematMap, HotBlocks, DT, SlotIndexes, MRI, SIRI, SIII,
1493- MF);
1493+ applyRemat (SRematMap, HotBlocks, DT, SlotIndexes, MRI, SIRI, SIII, MF);
14941494 LLVM_DEBUG (llvm::dbgs () << " after hotremat" ; MF.print (dbgs ()););
14951495 }
14961496
@@ -1530,4 +1530,3 @@ char &llvm::AMDGPUHotBlockRematerializeID = AMDGPUHotBlockRematerialize::ID;
15301530FunctionPass *llvm::createAMDGPUHotBlockRematerializePass () {
15311531 return new AMDGPUHotBlockRematerialize ();
15321532}
1533-
0 commit comments