1919#include " SIInstrInfo.h"
2020#include " llvm/ADT/PostOrderIterator.h"
2121#include " llvm/CodeGen/MachineFunctionPass.h"
22+ #include " llvm/CodeGen/MachinePassManager.h"
2223
2324using namespace llvm ;
2425
@@ -40,15 +41,11 @@ struct MBBInfo {
4041
4142using MBBInfoSet = DenseMap<const MachineBasicBlock *, MBBInfo>;
4243
43- class AMDGPUSetWavePriority : public MachineFunctionPass {
44+ class AMDGPUSetWavePriority {
4445public:
4546 static char ID;
4647
47- AMDGPUSetWavePriority () : MachineFunctionPass(ID) {}
48-
49- StringRef getPassName () const override { return " Set wave priority" ; }
50-
51- bool runOnMachineFunction (MachineFunction &MF) override ;
48+ bool run (MachineFunction &MF);
5249
5350private:
5451 MachineInstr *BuildSetprioMI (MachineBasicBlock &MBB,
@@ -58,15 +55,31 @@ class AMDGPUSetWavePriority : public MachineFunctionPass {
5855 const SIInstrInfo *TII;
5956};
6057
58+ class AMDGPUSetWavePriorityLegacy : public MachineFunctionPass {
59+ public:
60+ static char ID;
61+
62+ AMDGPUSetWavePriorityLegacy () : MachineFunctionPass(ID) {}
63+
64+ StringRef getPassName () const override { return " Set wave priority" ; }
65+
66+ bool runOnMachineFunction (MachineFunction &MF) override {
67+ if (skipFunction (MF.getFunction ()))
68+ return false ;
69+
70+ return AMDGPUSetWavePriority ().run (MF);
71+ }
72+ };
73+
6174} // End anonymous namespace.
6275
63- INITIALIZE_PASS (AMDGPUSetWavePriority , DEBUG_TYPE, " Set wave priority" , false ,
64- false )
76+ INITIALIZE_PASS (AMDGPUSetWavePriorityLegacy , DEBUG_TYPE, " Set wave priority" ,
77+ false , false )
6578
66- char AMDGPUSetWavePriority ::ID = 0;
79+ char AMDGPUSetWavePriorityLegacy ::ID = 0;
6780
6881FunctionPass *llvm::createAMDGPUSetWavePriorityPass () {
69- return new AMDGPUSetWavePriority ();
82+ return new AMDGPUSetWavePriorityLegacy ();
7083}
7184
7285MachineInstr *
@@ -96,12 +109,21 @@ static bool isVMEMLoad(const MachineInstr &MI) {
96109 return SIInstrInfo::isVMEM (MI) && MI.mayLoad ();
97110}
98111
99- bool AMDGPUSetWavePriority::runOnMachineFunction (MachineFunction &MF) {
112+ PreservedAnalyses
113+ llvm::AMDGPUSetWavePriorityPass::run (MachineFunction &MF,
114+ MachineFunctionAnalysisManager &MFAM) {
115+ if (!AMDGPUSetWavePriority ().run (MF))
116+ return PreservedAnalyses::all ();
117+
118+ return getMachineFunctionPassPreservedAnalyses ();
119+ }
120+
121+ bool AMDGPUSetWavePriority::run (MachineFunction &MF) {
100122 const unsigned HighPriority = 3 ;
101123 const unsigned LowPriority = 0 ;
102124
103125 Function &F = MF.getFunction ();
104- if (skipFunction (F) || !AMDGPU::isEntryFunctionCC (F.getCallingConv ()))
126+ if (!AMDGPU::isEntryFunctionCC (F.getCallingConv ()))
105127 return false ;
106128
107129 const GCNSubtarget &ST = MF.getSubtarget <GCNSubtarget>();
0 commit comments