@@ -24,7 +24,7 @@ using namespace llvm;
2424
2525namespace {
2626
27- class SIPreEmitPeephole : public MachineFunctionPass {
27+ class SIPreEmitPeephole {
2828private:
2929 const SIInstrInfo *TII = nullptr ;
3030 const SIRegisterInfo *TRI = nullptr ;
@@ -40,24 +40,31 @@ class SIPreEmitPeephole : public MachineFunctionPass {
4040 const MachineBasicBlock &To) const ;
4141 bool removeExeczBranch (MachineInstr &MI, MachineBasicBlock &SrcMBB);
4242
43+ public:
44+ bool run (MachineFunction &MF);
45+ };
46+
47+ class SIPreEmitPeepholeLegacy : public MachineFunctionPass {
4348public:
4449 static char ID;
4550
46- SIPreEmitPeephole () : MachineFunctionPass(ID) {
47- initializeSIPreEmitPeepholePass (*PassRegistry::getPassRegistry ());
51+ SIPreEmitPeepholeLegacy () : MachineFunctionPass(ID) {
52+ initializeSIPreEmitPeepholeLegacyPass (*PassRegistry::getPassRegistry ());
4853 }
4954
50- bool runOnMachineFunction (MachineFunction &MF) override ;
55+ bool runOnMachineFunction (MachineFunction &MF) override {
56+ return SIPreEmitPeephole ().run (MF);
57+ }
5158};
5259
5360} // End anonymous namespace.
5461
55- INITIALIZE_PASS (SIPreEmitPeephole , DEBUG_TYPE,
62+ INITIALIZE_PASS (SIPreEmitPeepholeLegacy , DEBUG_TYPE,
5663 " SI peephole optimizations" , false , false )
5764
58- char SIPreEmitPeephole ::ID = 0;
65+ char SIPreEmitPeepholeLegacy ::ID = 0;
5966
60- char &llvm::SIPreEmitPeepholeID = SIPreEmitPeephole ::ID;
67+ char &llvm::SIPreEmitPeepholeID = SIPreEmitPeepholeLegacy ::ID;
6168
6269bool SIPreEmitPeephole::optimizeVccBranch (MachineInstr &MI) const {
6370 // Match:
@@ -410,7 +417,16 @@ bool SIPreEmitPeephole::removeExeczBranch(MachineInstr &MI,
410417 return true ;
411418}
412419
413- bool SIPreEmitPeephole::runOnMachineFunction (MachineFunction &MF) {
420+ PreservedAnalyses
421+ llvm::SIPreEmitPeepholePass::run (MachineFunction &MF,
422+ MachineFunctionAnalysisManager &MFAM) {
423+ if (!SIPreEmitPeephole ().run (MF))
424+ return PreservedAnalyses::all ();
425+
426+ return getMachineFunctionPassPreservedAnalyses ();
427+ }
428+
429+ bool SIPreEmitPeephole::run (MachineFunction &MF) {
414430 const GCNSubtarget &ST = MF.getSubtarget <GCNSubtarget>();
415431 TII = ST.getInstrInfo ();
416432 TRI = &TII->getRegisterInfo ();
0 commit comments