Skip to content

Commit c9cbc85

Browse files
committed
remove PM from impl class
1 parent 1d24833 commit c9cbc85

File tree

1 file changed

+54
-24
lines changed

1 file changed

+54
-24
lines changed

llvm/lib/CodeGen/MachineSink.cpp

Lines changed: 54 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
#include "llvm/Analysis/AliasAnalysis.h"
2828
#include "llvm/Analysis/CFG.h"
2929
#include "llvm/Analysis/ProfileSummaryInfo.h"
30+
#include "llvm/CodeGen/LiveIntervals.h"
31+
#include "llvm/CodeGen/LiveVariables.h"
3032
#include "llvm/CodeGen/MachineBasicBlock.h"
3133
#include "llvm/CodeGen/MachineBlockFrequencyInfo.h"
3234
#include "llvm/CodeGen/MachineBranchProbabilityInfo.h"
@@ -44,6 +46,7 @@
4446
#include "llvm/CodeGen/MachineSizeOpts.h"
4547
#include "llvm/CodeGen/RegisterClassInfo.h"
4648
#include "llvm/CodeGen/RegisterPressure.h"
49+
#include "llvm/CodeGen/SlotIndexes.h"
4750
#include "llvm/CodeGen/TargetInstrInfo.h"
4851
#include "llvm/CodeGen/TargetPassConfig.h"
4952
#include "llvm/CodeGen/TargetRegisterInfo.h"
@@ -135,8 +138,11 @@ class MachineSinking {
135138
AliasAnalysis *AA = nullptr;
136139
RegisterClassInfo RegClassInfo;
137140
TargetSchedModel SchedModel;
138-
Pass *LegacyPass;
139-
MachineFunctionAnalysisManager *MFAM;
141+
// Required for split critical edge
142+
LiveIntervals *LIS;
143+
SlotIndexes *SI;
144+
LiveVariables *LV;
145+
MachineLoopInfo *MLI;
140146

141147
// Remember which edges have been considered for breaking.
142148
SmallSet<std::pair<MachineBasicBlock *, MachineBasicBlock *>, 8>
@@ -194,9 +200,14 @@ class MachineSinking {
194200
bool EnableSinkAndFold;
195201

196202
public:
197-
MachineSinking(Pass *LegacyPass, MachineFunctionAnalysisManager *MFAM,
198-
bool EnableSinkAndFold)
199-
: LegacyPass(LegacyPass), MFAM(MFAM),
203+
MachineSinking(bool EnableSinkAndFold, MachineDominatorTree *DT,
204+
MachinePostDominatorTree *PDT, LiveVariables *LV,
205+
MachineLoopInfo *MLI, SlotIndexes *SI, LiveIntervals *LIS,
206+
MachineCycleInfo *CI, ProfileSummaryInfo *PSI,
207+
MachineBlockFrequencyInfo *MBFI,
208+
const MachineBranchProbabilityInfo *MBPI, AliasAnalysis *AA)
209+
: DT(DT), PDT(PDT), CI(CI), PSI(PSI), MBFI(MBFI), MBPI(MBPI), AA(AA),
210+
LIS(LIS), SI(SI), LV(LV), MLI(MLI),
200211
EnableSinkAndFold(EnableSinkAndFold) {}
201212

202213
bool run(MachineFunction &MF);
@@ -746,7 +757,23 @@ void MachineSinking::FindCycleSinkCandidates(
746757
PreservedAnalyses
747758
MachineSinkingPass::run(MachineFunction &MF,
748759
MachineFunctionAnalysisManager &MFAM) {
749-
MachineSinking Impl(nullptr, &MFAM, EnableSinkAndFold);
760+
auto *DT = &MFAM.getResult<MachineDominatorTreeAnalysis>(MF);
761+
auto *PDT = &MFAM.getResult<MachinePostDominatorTreeAnalysis>(MF);
762+
auto *CI = &MFAM.getResult<MachineCycleAnalysis>(MF);
763+
auto *PSI = MFAM.getCachedResult<ProfileSummaryAnalysis>(MF);
764+
auto *MBFI = UseBlockFreqInfo
765+
? &MFAM.getResult<MachineBlockFrequencyAnalysis>(MF)
766+
: nullptr;
767+
auto *MBPI = &MFAM.getResult<MachineBranchProbabilityAnalysis>(MF);
768+
auto *AA = &MFAM.getResult<FunctionAnalysisManagerMachineFunctionProxy>(MF)
769+
.getManager()
770+
.getResult<AAManager>(MF.getFunction());
771+
auto *LIS = &MFAM.getResult<LiveIntervalsAnalysis>(MF);
772+
auto *SI = &MFAM.getResult<SlotIndexesAnalysis>(MF);
773+
auto *LV = &MFAM.getResult<LiveVariablesAnalysis>(MF);
774+
auto *MLI = &MFAM.getResult<MachineLoopAnalysis>(MF);
775+
MachineSinking Impl(EnableSinkAndFold, DT, PDT, LV, MLI, SI, LIS, CI, PSI,
776+
MBFI, MBPI, AA);
750777
bool Changed = Impl.run(MF);
751778
if (!Changed)
752779
return PreservedAnalyses::all();
@@ -770,7 +797,25 @@ bool MachineSinkingLegacy::runOnMachineFunction(MachineFunction &MF) {
770797
TargetPassConfig *PassConfig = &getAnalysis<TargetPassConfig>();
771798
bool EnableSinkAndFold = PassConfig->getEnableSinkAndFold();
772799

773-
MachineSinking Impl(this, nullptr, EnableSinkAndFold);
800+
auto *DT = &getAnalysis<MachineDominatorTreeWrapperPass>().getDomTree();
801+
auto *PDT =
802+
&getAnalysis<MachinePostDominatorTreeWrapperPass>().getPostDomTree();
803+
auto *CI = &getAnalysis<MachineCycleInfoWrapperPass>().getCycleInfo();
804+
auto *PSI = &getAnalysis<ProfileSummaryInfoWrapperPass>().getPSI();
805+
auto *MBFI =
806+
UseBlockFreqInfo
807+
? &getAnalysis<MachineBlockFrequencyInfoWrapperPass>().getMBFI()
808+
: nullptr;
809+
auto *MBPI =
810+
&getAnalysis<MachineBranchProbabilityInfoWrapperPass>().getMBPI();
811+
auto *AA = &getAnalysis<AAResultsWrapperPass>().getAAResults();
812+
auto *LIS = &getAnalysis<LiveIntervalsWrapperPass>().getLIS();
813+
auto *SI = &getAnalysis<SlotIndexesWrapperPass>().getSI();
814+
auto *LV = &getAnalysis<LiveVariablesWrapperPass>().getLV();
815+
auto *MLI = &getAnalysis<MachineLoopInfoWrapperPass>().getLI();
816+
817+
MachineSinking Impl(EnableSinkAndFold, DT, PDT, LV, MLI, SI, LIS, CI, PSI,
818+
MBFI, MBPI, AA);
774819
return Impl.run(MF);
775820
}
776821

@@ -786,21 +831,6 @@ bool MachineSinking::run(MachineFunction &MF) {
786831
TII = STI->getInstrInfo();
787832
TRI = STI->getRegisterInfo();
788833
MRI = &MF.getRegInfo();
789-
DT = GET_ANALYSIS(MachineDominatorTree, , getDomTree);
790-
PDT = GET_ANALYSIS(MachinePostDominatorTree, , getPostDomTree);
791-
CI = GET_ANALYSIS(MachineCycle, Info, getCycleInfo);
792-
PSI = (LegacyPass)
793-
? &LegacyPass->getAnalysis<ProfileSummaryInfoWrapperPass>().getPSI()
794-
: MFAM->getResult<ModuleAnalysisManagerMachineFunctionProxy>(MF)
795-
.getCachedResult<ProfileSummaryAnalysis>(*MF.getFunction().getParent());
796-
MBFI = UseBlockFreqInfo ? GET_ANALYSIS(MachineBlockFrequency, Info, getMBFI)
797-
: nullptr;
798-
MBPI = GET_ANALYSIS(MachineBranchProbability, Info, getMBPI);
799-
AA = (LegacyPass)
800-
? &LegacyPass->getAnalysis<AAResultsWrapperPass>().getAAResults()
801-
: &MFAM->getResult<FunctionAnalysisManagerMachineFunctionProxy>(MF)
802-
.getManager()
803-
.getResult<AAManager>(MF.getFunction());
804834

805835
RegClassInfo.runOnMachineFunction(MF);
806836

@@ -820,8 +850,8 @@ bool MachineSinking::run(MachineFunction &MF) {
820850
MachineDomTreeUpdater MDTU(DT, PDT,
821851
MachineDomTreeUpdater::UpdateStrategy::Lazy);
822852
for (const auto &Pair : ToSplit) {
823-
auto NewSucc =
824-
Pair.first->SplitCriticalEdge(Pair.second, LegacyPass, MFAM, nullptr, &MDTU);
853+
auto NewSucc = Pair.first->SplitCriticalEdge(
854+
Pair.second, {LIS, SI, LV, MLI}, nullptr, &MDTU);
825855
if (NewSucc != nullptr) {
826856
LLVM_DEBUG(dbgs() << " *** Splitting critical edge: "
827857
<< printMBBReference(*Pair.first) << " -- "

0 commit comments

Comments
 (0)