2020// /
2121// ===----------------------------------------------------------------------===//
2222
23+ #include " llvm/CodeGen/FixupStatepointCallerSaved.h"
2324#include " llvm/ADT/SmallSet.h"
2425#include " llvm/ADT/Statistic.h"
2526#include " llvm/CodeGen/MachineFrameInfo.h"
@@ -58,14 +59,18 @@ static cl::opt<unsigned> MaxStatepointsWithRegs(
5859
5960namespace {
6061
61- class FixupStatepointCallerSaved : public MachineFunctionPass {
62+ struct FixupStatepointCallerSavedImpl {
63+ bool run (MachineFunction &MF);
64+ };
65+
66+ class FixupStatepointCallerSavedLegacy : public MachineFunctionPass {
6267public:
6368 static char ID;
6469
65- FixupStatepointCallerSaved () : MachineFunctionPass(ID) {
66- initializeFixupStatepointCallerSavedPass (*PassRegistry::getPassRegistry ());
70+ FixupStatepointCallerSavedLegacy () : MachineFunctionPass(ID) {
71+ initializeFixupStatepointCallerSavedLegacyPass (
72+ *PassRegistry::getPassRegistry ());
6773 }
68-
6974 void getAnalysisUsage (AnalysisUsage &AU) const override {
7075 AU.setPreservesCFG ();
7176 MachineFunctionPass::getAnalysisUsage (AU);
@@ -80,12 +85,12 @@ class FixupStatepointCallerSaved : public MachineFunctionPass {
8085
8186} // End anonymous namespace.
8287
83- char FixupStatepointCallerSaved ::ID = 0 ;
84- char &llvm::FixupStatepointCallerSavedID = FixupStatepointCallerSaved ::ID;
88+ char FixupStatepointCallerSavedLegacy ::ID = 0 ;
89+ char &llvm::FixupStatepointCallerSavedID = FixupStatepointCallerSavedLegacy ::ID;
8590
86- INITIALIZE_PASS_BEGIN (FixupStatepointCallerSaved , DEBUG_TYPE,
91+ INITIALIZE_PASS_BEGIN (FixupStatepointCallerSavedLegacy , DEBUG_TYPE,
8792 " Fixup Statepoint Caller Saved" , false , false )
88- INITIALIZE_PASS_END(FixupStatepointCallerSaved , DEBUG_TYPE,
93+ INITIALIZE_PASS_END(FixupStatepointCallerSavedLegacy , DEBUG_TYPE,
8994 " Fixup Statepoint Caller Saved" , false , false )
9095
9196// Utility function to get size of the register.
@@ -590,10 +595,7 @@ class StatepointProcessor {
590595};
591596} // namespace
592597
593- bool FixupStatepointCallerSaved::runOnMachineFunction (MachineFunction &MF) {
594- if (skipFunction (MF.getFunction ()))
595- return false ;
596-
598+ bool FixupStatepointCallerSavedImpl::run (MachineFunction &MF) {
597599 const Function &F = MF.getFunction ();
598600 if (!F.hasGC ())
599601 return false ;
@@ -620,3 +622,23 @@ bool FixupStatepointCallerSaved::runOnMachineFunction(MachineFunction &MF) {
620622 }
621623 return Changed;
622624}
625+
626+ bool FixupStatepointCallerSavedLegacy::runOnMachineFunction (
627+ MachineFunction &MF) {
628+ if (skipFunction (MF.getFunction ()))
629+ return false ;
630+
631+ return FixupStatepointCallerSavedImpl ().run (MF);
632+ }
633+
634+ PreservedAnalyses
635+ FixupStatepointCallerSavedPass::run (MachineFunction &MF,
636+ MachineFunctionAnalysisManager &MFAM) {
637+
638+ if (!FixupStatepointCallerSavedImpl ().run (MF))
639+ return PreservedAnalyses::all ();
640+
641+ auto PA = getMachineFunctionPassPreservedAnalyses ();
642+ PA.preserveSet <CFGAnalyses>();
643+ return PA;
644+ }
0 commit comments