@@ -23,22 +23,13 @@ using namespace llvm;
2323
2424namespace {
2525
26- class AMDGPUInsertDelayAlu : public MachineFunctionPass {
26+ class AMDGPUInsertDelayAlu {
2727public:
28- static char ID;
29-
3028 const SIInstrInfo *SII;
3129 const TargetRegisterInfo *TRI;
3230
3331 const TargetSchedModel *SchedModel;
3432
35- AMDGPUInsertDelayAlu () : MachineFunctionPass(ID) {}
36-
37- void getAnalysisUsage (AnalysisUsage &AU) const override {
38- AU.setPreservesCFG ();
39- MachineFunctionPass::getAnalysisUsage (AU);
40- }
41-
4233 // Return true if MI waits for all outstanding VALU instructions to complete.
4334 static bool instructionWaitsForVALU (const MachineInstr &MI) {
4435 // These instruction types wait for VA_VDST==0 before issuing.
@@ -416,10 +407,7 @@ class AMDGPUInsertDelayAlu : public MachineFunctionPass {
416407 return Changed;
417408 }
418409
419- bool runOnMachineFunction (MachineFunction &MF) override {
420- if (skipFunction (MF.getFunction ()))
421- return false ;
422-
410+ bool run (MachineFunction &MF) {
423411 LLVM_DEBUG (dbgs () << " AMDGPUInsertDelayAlu running on " << MF.getName ()
424412 << " \n " );
425413
@@ -454,11 +442,39 @@ class AMDGPUInsertDelayAlu : public MachineFunctionPass {
454442 }
455443};
456444
445+ class AMDGPUInsertDelayAluLegacy : public MachineFunctionPass {
446+ public:
447+ static char ID;
448+
449+ AMDGPUInsertDelayAluLegacy () : MachineFunctionPass(ID) {}
450+
451+ void getAnalysisUsage (AnalysisUsage &AU) const override {
452+ AU.setPreservesCFG ();
453+ MachineFunctionPass::getAnalysisUsage (AU);
454+ }
455+
456+ bool runOnMachineFunction (MachineFunction &MF) override {
457+ if (skipFunction (MF.getFunction ()))
458+ return false ;
459+ AMDGPUInsertDelayAlu Impl;
460+ return Impl.run (MF);
461+ }
462+ };
457463} // namespace
458464
459- char AMDGPUInsertDelayAlu::ID = 0 ;
465+ PreservedAnalyses
466+ AMDGPUInsertDelayAluPass::run (MachineFunction &MF,
467+ MachineFunctionAnalysisManager &MFAM) {
468+ if (!AMDGPUInsertDelayAlu ().run (MF))
469+ return PreservedAnalyses::all ();
470+ auto PA = getMachineFunctionPassPreservedAnalyses ();
471+ PA.preserveSet <CFGAnalyses>();
472+ return PA;
473+ } // end namespace llvm
474+
475+ char AMDGPUInsertDelayAluLegacy::ID = 0 ;
460476
461- char &llvm::AMDGPUInsertDelayAluID = AMDGPUInsertDelayAlu ::ID;
477+ char &llvm::AMDGPUInsertDelayAluID = AMDGPUInsertDelayAluLegacy ::ID;
462478
463- INITIALIZE_PASS (AMDGPUInsertDelayAlu , DEBUG_TYPE, " AMDGPU Insert Delay ALU " ,
464- false , false )
479+ INITIALIZE_PASS (AMDGPUInsertDelayAluLegacy , DEBUG_TYPE,
480+ " AMDGPU Insert Delay ALU " , false , false )
0 commit comments