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.
@@ -588,10 +593,7 @@ class StatepointProcessor {
588593};
589594} // namespace
590595
591- bool FixupStatepointCallerSaved::runOnMachineFunction (MachineFunction &MF) {
592- if (skipFunction (MF.getFunction ()))
593- return false ;
594-
596+ bool FixupStatepointCallerSavedImpl::run (MachineFunction &MF) {
595597 const Function &F = MF.getFunction ();
596598 if (!F.hasGC ())
597599 return false ;
@@ -618,3 +620,23 @@ bool FixupStatepointCallerSaved::runOnMachineFunction(MachineFunction &MF) {
618620 }
619621 return Changed;
620622}
623+
624+ bool FixupStatepointCallerSavedLegacy::runOnMachineFunction (
625+ MachineFunction &MF) {
626+ if (skipFunction (MF.getFunction ()))
627+ return false ;
628+
629+ return FixupStatepointCallerSavedImpl ().run (MF);
630+ }
631+
632+ PreservedAnalyses
633+ FixupStatepointCallerSavedPass::run (MachineFunction &MF,
634+ MachineFunctionAnalysisManager &MFAM) {
635+
636+ if (!FixupStatepointCallerSavedImpl ().run (MF))
637+ return PreservedAnalyses::all ();
638+
639+ auto PA = getMachineFunctionPassPreservedAnalyses ();
640+ PA.preserveSet <CFGAnalyses>();
641+ return PA;
642+ }
0 commit comments