Skip to content

Commit 53a87f3

Browse files
committed
fix analyses required for split critical edge
1 parent 91b8868 commit 53a87f3

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

llvm/lib/CodeGen/MachineSink.cpp

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -758,18 +758,20 @@ MachineSinkingPass::run(MachineFunction &MF,
758758
auto *DT = &MFAM.getResult<MachineDominatorTreeAnalysis>(MF);
759759
auto *PDT = &MFAM.getResult<MachinePostDominatorTreeAnalysis>(MF);
760760
auto *CI = &MFAM.getResult<MachineCycleAnalysis>(MF);
761-
auto *PSI = MFAM.getCachedResult<ProfileSummaryAnalysis>(MF);
761+
auto *PSI = MFAM.getResult<ModuleAnalysisManagerMachineFunctionProxy>(MF)
762+
.getCachedResult<ProfileSummaryAnalysis>(
763+
*MF.getFunction().getParent());
762764
auto *MBFI = UseBlockFreqInfo
763765
? &MFAM.getResult<MachineBlockFrequencyAnalysis>(MF)
764766
: nullptr;
765767
auto *MBPI = &MFAM.getResult<MachineBranchProbabilityAnalysis>(MF);
766768
auto *AA = &MFAM.getResult<FunctionAnalysisManagerMachineFunctionProxy>(MF)
767769
.getManager()
768770
.getResult<AAManager>(MF.getFunction());
769-
auto *LIS = &MFAM.getResult<LiveIntervalsAnalysis>(MF);
770-
auto *SI = &MFAM.getResult<SlotIndexesAnalysis>(MF);
771-
auto *LV = &MFAM.getResult<LiveVariablesAnalysis>(MF);
772-
auto *MLI = &MFAM.getResult<MachineLoopAnalysis>(MF);
771+
auto *LIS = MFAM.getCachedResult<LiveIntervalsAnalysis>(MF);
772+
auto *SI = MFAM.getCachedResult<SlotIndexesAnalysis>(MF);
773+
auto *LV = MFAM.getCachedResult<LiveVariablesAnalysis>(MF);
774+
auto *MLI = MFAM.getCachedResult<MachineLoopAnalysis>(MF);
773775
MachineSinking Impl(EnableSinkAndFold, DT, PDT, LV, MLI, SI, LIS, CI, PSI,
774776
MBFI, MBPI, AA);
775777
bool Changed = Impl.run(MF);
@@ -807,10 +809,15 @@ bool MachineSinkingLegacy::runOnMachineFunction(MachineFunction &MF) {
807809
auto *MBPI =
808810
&getAnalysis<MachineBranchProbabilityInfoWrapperPass>().getMBPI();
809811
auto *AA = &getAnalysis<AAResultsWrapperPass>().getAAResults();
810-
auto *LIS = &getAnalysis<LiveIntervalsWrapperPass>().getLIS();
811-
auto *SI = &getAnalysis<SlotIndexesWrapperPass>().getSI();
812-
auto *LV = &getAnalysis<LiveVariablesWrapperPass>().getLV();
813-
auto *MLI = &getAnalysis<MachineLoopInfoWrapperPass>().getLI();
812+
// Get analyses for split critical edge.
813+
auto *LISWrapper = getAnalysisIfAvailable<LiveIntervalsWrapperPass>();
814+
auto *LIS = LISWrapper ? &LISWrapper->getLIS() : nullptr;
815+
auto *SIWrapper = getAnalysisIfAvailable<SlotIndexesWrapperPass>();
816+
auto *SI = SIWrapper ? &SIWrapper->getSI() : nullptr;
817+
auto *LVWrapper = getAnalysisIfAvailable<LiveVariablesWrapperPass>();
818+
auto *LV = LVWrapper ? &LVWrapper->getLV() : nullptr;
819+
auto *MLIWrapper = getAnalysisIfAvailable<MachineLoopInfoWrapperPass>();
820+
auto *MLI = MLIWrapper ? &MLIWrapper->getLI() : nullptr;
814821

815822
MachineSinking Impl(EnableSinkAndFold, DT, PDT, LV, MLI, SI, LIS, CI, PSI,
816823
MBFI, MBPI, AA);

0 commit comments

Comments
 (0)