diff options
author | paperchalice <liujunchang97@outlook.com> | 2024-07-09 09:11:18 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-09 09:11:18 +0800 |
commit | 79d0de2ac37b6b7d66720611935d1dd7fc4fbd43 (patch) | |
tree | 27fc88539708d84f03ca11a890551780e33a5f2c /llvm/lib/CodeGen | |
parent | afa6bed8afe9011c07c682a0a24362260d92cfdd (diff) | |
download | llvm-79d0de2ac37b6b7d66720611935d1dd7fc4fbd43.zip llvm-79d0de2ac37b6b7d66720611935d1dd7fc4fbd43.tar.gz llvm-79d0de2ac37b6b7d66720611935d1dd7fc4fbd43.tar.bz2 |
[CodeGen][NewPM] Port `machine-loops` to new pass manager (#97793)
- Add `MachineLoopAnalysis`.
- Add `MachineLoopPrinterPass`.
- Convert to `MachineLoopInfoWrapperPass` in legacy pass manager.
Diffstat (limited to 'llvm/lib/CodeGen')
30 files changed, 146 insertions, 107 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index 0264712..1f59ec5 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -1703,10 +1703,11 @@ void AsmPrinter::emitFunctionBody() { } // Get MachineLoopInfo or compute it on the fly if it's unavailable - MLI = getAnalysisIfAvailable<MachineLoopInfo>(); + auto *MLIWrapper = getAnalysisIfAvailable<MachineLoopInfoWrapperPass>(); + MLI = MLIWrapper ? &MLIWrapper->getLI() : nullptr; if (!MLI) { OwnedMLI = std::make_unique<MachineLoopInfo>(); - OwnedMLI->getBase().analyze(MDT->getBase()); + OwnedMLI->analyze(MDT->getBase()); MLI = OwnedMLI.get(); } } diff --git a/llvm/lib/CodeGen/BranchFolding.cpp b/llvm/lib/CodeGen/BranchFolding.cpp index 1b6a6ee..afe7970 100644 --- a/llvm/lib/CodeGen/BranchFolding.cpp +++ b/llvm/lib/CodeGen/BranchFolding.cpp @@ -415,7 +415,7 @@ MachineBasicBlock *BranchFolder::SplitMBBAt(MachineBasicBlock &CurMBB, // NewMBB belongs to the same loop as CurMBB. if (MLI) if (MachineLoop *ML = MLI->getLoopFor(&CurMBB)) - ML->addBasicBlockToLoop(NewMBB, MLI->getBase()); + ML->addBasicBlockToLoop(NewMBB, *MLI); // NewMBB inherits CurMBB's block frequency. MBBFreqInfo.setBlockFreq(NewMBB, MBBFreqInfo.getBlockFreq(&CurMBB)); diff --git a/llvm/lib/CodeGen/CodeGen.cpp b/llvm/lib/CodeGen/CodeGen.cpp index 7dcb0ea..35e2751 100644 --- a/llvm/lib/CodeGen/CodeGen.cpp +++ b/llvm/lib/CodeGen/CodeGen.cpp @@ -84,7 +84,7 @@ void llvm::initializeCodeGen(PassRegistry &Registry) { initializeMachineFunctionPrinterPassPass(Registry); initializeMachineLateInstrsCleanupPass(Registry); initializeMachineLICMPass(Registry); - initializeMachineLoopInfoPass(Registry); + initializeMachineLoopInfoWrapperPassPass(Registry); initializeMachineModuleInfoWrapperPassPass(Registry); initializeMachineOptimizationRemarkEmitterPassPass(Registry); initializeMachineOutlinerPass(Registry); diff --git a/llvm/lib/CodeGen/EarlyIfConversion.cpp b/llvm/lib/CodeGen/EarlyIfConversion.cpp index 5f3e850..a5c9949 100644 --- a/llvm/lib/CodeGen/EarlyIfConversion.cpp +++ b/llvm/lib/CodeGen/EarlyIfConversion.cpp @@ -797,8 +797,8 @@ void EarlyIfConverter::getAnalysisUsage(AnalysisUsage &AU) const { AU.addRequired<MachineBranchProbabilityInfoWrapperPass>(); AU.addRequired<MachineDominatorTreeWrapperPass>(); AU.addPreserved<MachineDominatorTreeWrapperPass>(); - AU.addRequired<MachineLoopInfo>(); - AU.addPreserved<MachineLoopInfo>(); + AU.addRequired<MachineLoopInfoWrapperPass>(); + AU.addPreserved<MachineLoopInfoWrapperPass>(); AU.addRequired<MachineTraceMetrics>(); AU.addPreserved<MachineTraceMetrics>(); MachineFunctionPass::getAnalysisUsage(AU); @@ -1087,7 +1087,7 @@ bool EarlyIfConverter::runOnMachineFunction(MachineFunction &MF) { SchedModel = STI.getSchedModel(); MRI = &MF.getRegInfo(); DomTree = &getAnalysis<MachineDominatorTreeWrapperPass>().getDomTree(); - Loops = &getAnalysis<MachineLoopInfo>(); + Loops = &getAnalysis<MachineLoopInfoWrapperPass>().getLI(); Traces = &getAnalysis<MachineTraceMetrics>(); MinInstr = nullptr; @@ -1150,8 +1150,8 @@ void EarlyIfPredicator::getAnalysisUsage(AnalysisUsage &AU) const { AU.addRequired<MachineBranchProbabilityInfoWrapperPass>(); AU.addRequired<MachineDominatorTreeWrapperPass>(); AU.addPreserved<MachineDominatorTreeWrapperPass>(); - AU.addRequired<MachineLoopInfo>(); - AU.addPreserved<MachineLoopInfo>(); + AU.addRequired<MachineLoopInfoWrapperPass>(); + AU.addPreserved<MachineLoopInfoWrapperPass>(); MachineFunctionPass::getAnalysisUsage(AU); } @@ -1221,7 +1221,7 @@ bool EarlyIfPredicator::runOnMachineFunction(MachineFunction &MF) { MRI = &MF.getRegInfo(); SchedModel.init(&STI); DomTree = &getAnalysis<MachineDominatorTreeWrapperPass>().getDomTree(); - Loops = &getAnalysis<MachineLoopInfo>(); + Loops = &getAnalysis<MachineLoopInfoWrapperPass>().getLI(); MBPI = &getAnalysis<MachineBranchProbabilityInfoWrapperPass>().getMBPI(); bool Changed = false; diff --git a/llvm/lib/CodeGen/LazyMachineBlockFrequencyInfo.cpp b/llvm/lib/CodeGen/LazyMachineBlockFrequencyInfo.cpp index 83b16fc..0cf01ed 100644 --- a/llvm/lib/CodeGen/LazyMachineBlockFrequencyInfo.cpp +++ b/llvm/lib/CodeGen/LazyMachineBlockFrequencyInfo.cpp @@ -24,7 +24,7 @@ using namespace llvm; INITIALIZE_PASS_BEGIN(LazyMachineBlockFrequencyInfoPass, DEBUG_TYPE, "Lazy Machine Block Frequency Analysis", true, true) INITIALIZE_PASS_DEPENDENCY(MachineBranchProbabilityInfoWrapperPass) -INITIALIZE_PASS_DEPENDENCY(MachineLoopInfo) +INITIALIZE_PASS_DEPENDENCY(MachineLoopInfoWrapperPass) INITIALIZE_PASS_END(LazyMachineBlockFrequencyInfoPass, DEBUG_TYPE, "Lazy Machine Block Frequency Analysis", true, true) @@ -63,7 +63,8 @@ LazyMachineBlockFrequencyInfoPass::calculateIfNotAvailable() const { } auto &MBPI = getAnalysis<MachineBranchProbabilityInfoWrapperPass>().getMBPI(); - auto *MLI = getAnalysisIfAvailable<MachineLoopInfo>(); + auto *MLIWrapper = getAnalysisIfAvailable<MachineLoopInfoWrapperPass>(); + auto *MLI = MLIWrapper ? &MLIWrapper->getLI() : nullptr; auto *MDTWrapper = getAnalysisIfAvailable<MachineDominatorTreeWrapperPass>(); auto *MDT = MDTWrapper ? &MDTWrapper->getDomTree() : nullptr; LLVM_DEBUG(dbgs() << "Building MachineBlockFrequencyInfo on the fly\n"); @@ -83,7 +84,7 @@ LazyMachineBlockFrequencyInfoPass::calculateIfNotAvailable() const { // Generate LoopInfo from it. OwnedMLI = std::make_unique<MachineLoopInfo>(); - OwnedMLI->getBase().analyze(MDT->getBase()); + OwnedMLI->analyze(MDT->getBase()); MLI = OwnedMLI.get(); } diff --git a/llvm/lib/CodeGen/MIRSampleProfile.cpp b/llvm/lib/CodeGen/MIRSampleProfile.cpp index 84e6c61..b77d8aa 100644 --- a/llvm/lib/CodeGen/MIRSampleProfile.cpp +++ b/llvm/lib/CodeGen/MIRSampleProfile.cpp @@ -72,7 +72,7 @@ INITIALIZE_PASS_BEGIN(MIRProfileLoaderPass, DEBUG_TYPE, INITIALIZE_PASS_DEPENDENCY(MachineBlockFrequencyInfo) INITIALIZE_PASS_DEPENDENCY(MachineDominatorTreeWrapperPass) INITIALIZE_PASS_DEPENDENCY(MachinePostDominatorTreeWrapperPass) -INITIALIZE_PASS_DEPENDENCY(MachineLoopInfo) +INITIALIZE_PASS_DEPENDENCY(MachineLoopInfoWrapperPass) INITIALIZE_PASS_DEPENDENCY(MachineOptimizationRemarkEmitterPass) INITIALIZE_PASS_END(MIRProfileLoaderPass, DEBUG_TYPE, "Load MIR Sample Profile", /* cfg = */ false, /* is_analysis = */ false) @@ -367,7 +367,7 @@ bool MIRProfileLoaderPass::runOnMachineFunction(MachineFunction &MF) { MIRSampleLoader->setInitVals( &getAnalysis<MachineDominatorTreeWrapperPass>().getDomTree(), &getAnalysis<MachinePostDominatorTreeWrapperPass>().getPostDomTree(), - &getAnalysis<MachineLoopInfo>(), MBFI, + &getAnalysis<MachineLoopInfoWrapperPass>().getLI(), MBFI, &getAnalysis<MachineOptimizationRemarkEmitterPass>().getORE()); MF.RenumberBlocks(); @@ -379,7 +379,8 @@ bool MIRProfileLoaderPass::runOnMachineFunction(MachineFunction &MF) { bool Changed = MIRSampleLoader->runOnFunction(MF); if (Changed) - MBFI->calculate(MF, *MBFI->getMBPI(), *&getAnalysis<MachineLoopInfo>()); + MBFI->calculate(MF, *MBFI->getMBPI(), + *&getAnalysis<MachineLoopInfoWrapperPass>().getLI()); if (ViewBFIAfter && ViewBlockLayoutWithBFI != GVDT_None && (ViewBlockFreqFuncName.empty() || @@ -403,7 +404,7 @@ void MIRProfileLoaderPass::getAnalysisUsage(AnalysisUsage &AU) const { AU.addRequired<MachineBlockFrequencyInfo>(); AU.addRequired<MachineDominatorTreeWrapperPass>(); AU.addRequired<MachinePostDominatorTreeWrapperPass>(); - AU.addRequiredTransitive<MachineLoopInfo>(); + AU.addRequiredTransitive<MachineLoopInfoWrapperPass>(); AU.addRequired<MachineOptimizationRemarkEmitterPass>(); MachineFunctionPass::getAnalysisUsage(AU); } diff --git a/llvm/lib/CodeGen/MLRegAllocEvictAdvisor.cpp b/llvm/lib/CodeGen/MLRegAllocEvictAdvisor.cpp index 5698f6d..7f90457 100644 --- a/llvm/lib/CodeGen/MLRegAllocEvictAdvisor.cpp +++ b/llvm/lib/CodeGen/MLRegAllocEvictAdvisor.cpp @@ -389,7 +389,7 @@ private: void getAnalysisUsage(AnalysisUsage &AU) const override { AU.addRequired<MachineBlockFrequencyInfo>(); - AU.addRequired<MachineLoopInfo>(); + AU.addRequired<MachineLoopInfoWrapperPass>(); RegAllocEvictionAdvisorAnalysis::getAnalysisUsage(AU); } @@ -407,7 +407,7 @@ private: } return std::make_unique<MLEvictAdvisor>( MF, RA, Runner.get(), getAnalysis<MachineBlockFrequencyInfo>(), - getAnalysis<MachineLoopInfo>()); + getAnalysis<MachineLoopInfoWrapperPass>().getLI()); } std::unique_ptr<MLModelRunner> Runner; }; @@ -496,7 +496,7 @@ private: void getAnalysisUsage(AnalysisUsage &AU) const override { AU.addRequired<MachineBlockFrequencyInfo>(); - AU.addRequired<MachineLoopInfo>(); + AU.addRequired<MachineLoopInfoWrapperPass>(); RegAllocEvictionAdvisorAnalysis::getAnalysisUsage(AU); } @@ -545,7 +545,7 @@ private: Log->switchContext(MF.getName()); return std::make_unique<DevelopmentModeEvictAdvisor>( MF, RA, Runner.get(), getAnalysis<MachineBlockFrequencyInfo>(), - getAnalysis<MachineLoopInfo>(), Log.get()); + getAnalysis<MachineLoopInfoWrapperPass>().getLI(), Log.get()); } std::unique_ptr<MLModelRunner> Runner; diff --git a/llvm/lib/CodeGen/MachineBasicBlock.cpp b/llvm/lib/CodeGen/MachineBasicBlock.cpp index 533ab7c..b5c3e16 100644 --- a/llvm/lib/CodeGen/MachineBasicBlock.cpp +++ b/llvm/lib/CodeGen/MachineBasicBlock.cpp @@ -1340,20 +1340,21 @@ MachineBasicBlock *MachineBasicBlock::SplitCriticalEdge( P.getAnalysisIfAvailable<MachineDominatorTreeWrapperPass>()) MDTWrapper->getDomTree().recordSplitCriticalEdge(this, Succ, NMBB); - if (MachineLoopInfo *MLI = P.getAnalysisIfAvailable<MachineLoopInfo>()) + auto *MLIWrapper = P.getAnalysisIfAvailable<MachineLoopInfoWrapperPass>(); + if (MachineLoopInfo *MLI = MLIWrapper ? &MLIWrapper->getLI() : nullptr) if (MachineLoop *TIL = MLI->getLoopFor(this)) { // If one or the other blocks were not in a loop, the new block is not // either, and thus LI doesn't need to be updated. if (MachineLoop *DestLoop = MLI->getLoopFor(Succ)) { if (TIL == DestLoop) { // Both in the same loop, the NMBB joins loop. - DestLoop->addBasicBlockToLoop(NMBB, MLI->getBase()); + DestLoop->addBasicBlockToLoop(NMBB, *MLI); } else if (TIL->contains(DestLoop)) { // Edge from an outer loop to an inner loop. Add to the outer loop. - TIL->addBasicBlockToLoop(NMBB, MLI->getBase()); + TIL->addBasicBlockToLoop(NMBB, *MLI); } else if (DestLoop->contains(TIL)) { // Edge from an inner loop to an outer loop. Add to the outer loop. - DestLoop->addBasicBlockToLoop(NMBB, MLI->getBase()); + DestLoop->addBasicBlockToLoop(NMBB, *MLI); } else { // Edge from two loops with no containment relation. Because these // are natural loops, we know that the destination block must be the @@ -1362,7 +1363,7 @@ MachineBasicBlock *MachineBasicBlock::SplitCriticalEdge( assert(DestLoop->getHeader() == Succ && "Should not create irreducible loops!"); if (MachineLoop *P = DestLoop->getParentLoop()) - P->addBasicBlockToLoop(NMBB, MLI->getBase()); + P->addBasicBlockToLoop(NMBB, *MLI); } } } diff --git a/llvm/lib/CodeGen/MachineBlockFrequencyInfo.cpp b/llvm/lib/CodeGen/MachineBlockFrequencyInfo.cpp index 2a68f18..5c053a4 100644 --- a/llvm/lib/CodeGen/MachineBlockFrequencyInfo.cpp +++ b/llvm/lib/CodeGen/MachineBlockFrequencyInfo.cpp @@ -164,7 +164,7 @@ struct DOTGraphTraits<MachineBlockFrequencyInfo *> INITIALIZE_PASS_BEGIN(MachineBlockFrequencyInfo, DEBUG_TYPE, "Machine Block Frequency Analysis", true, true) INITIALIZE_PASS_DEPENDENCY(MachineBranchProbabilityInfoWrapperPass) -INITIALIZE_PASS_DEPENDENCY(MachineLoopInfo) +INITIALIZE_PASS_DEPENDENCY(MachineLoopInfoWrapperPass) INITIALIZE_PASS_END(MachineBlockFrequencyInfo, DEBUG_TYPE, "Machine Block Frequency Analysis", true, true) @@ -186,7 +186,7 @@ MachineBlockFrequencyInfo::~MachineBlockFrequencyInfo() = default; void MachineBlockFrequencyInfo::getAnalysisUsage(AnalysisUsage &AU) const { AU.addRequired<MachineBranchProbabilityInfoWrapperPass>(); - AU.addRequired<MachineLoopInfo>(); + AU.addRequired<MachineLoopInfoWrapperPass>(); AU.setPreservesAll(); MachineFunctionPass::getAnalysisUsage(AU); } @@ -210,7 +210,7 @@ void MachineBlockFrequencyInfo::calculate( bool MachineBlockFrequencyInfo::runOnMachineFunction(MachineFunction &F) { MachineBranchProbabilityInfo &MBPI = getAnalysis<MachineBranchProbabilityInfoWrapperPass>().getMBPI(); - MachineLoopInfo &MLI = getAnalysis<MachineLoopInfo>(); + MachineLoopInfo &MLI = getAnalysis<MachineLoopInfoWrapperPass>().getLI(); calculate(F, MBPI, MLI); return false; } diff --git a/llvm/lib/CodeGen/MachineBlockPlacement.cpp b/llvm/lib/CodeGen/MachineBlockPlacement.cpp index a229475..14e0126 100644 --- a/llvm/lib/CodeGen/MachineBlockPlacement.cpp +++ b/llvm/lib/CodeGen/MachineBlockPlacement.cpp @@ -612,7 +612,7 @@ public: AU.addRequired<MachineBlockFrequencyInfo>(); if (TailDupPlacement) AU.addRequired<MachinePostDominatorTreeWrapperPass>(); - AU.addRequired<MachineLoopInfo>(); + AU.addRequired<MachineLoopInfoWrapperPass>(); AU.addRequired<ProfileSummaryInfoWrapperPass>(); AU.addRequired<TargetPassConfig>(); MachineFunctionPass::getAnalysisUsage(AU); @@ -630,7 +630,7 @@ INITIALIZE_PASS_BEGIN(MachineBlockPlacement, DEBUG_TYPE, INITIALIZE_PASS_DEPENDENCY(MachineBranchProbabilityInfoWrapperPass) INITIALIZE_PASS_DEPENDENCY(MachineBlockFrequencyInfo) INITIALIZE_PASS_DEPENDENCY(MachinePostDominatorTreeWrapperPass) -INITIALIZE_PASS_DEPENDENCY(MachineLoopInfo) +INITIALIZE_PASS_DEPENDENCY(MachineLoopInfoWrapperPass) INITIALIZE_PASS_DEPENDENCY(ProfileSummaryInfoWrapperPass) INITIALIZE_PASS_END(MachineBlockPlacement, DEBUG_TYPE, "Branch Probability Basic Block Placement", false, false) @@ -3428,7 +3428,7 @@ bool MachineBlockPlacement::runOnMachineFunction(MachineFunction &MF) { MBPI = &getAnalysis<MachineBranchProbabilityInfoWrapperPass>().getMBPI(); MBFI = std::make_unique<MBFIWrapper>( getAnalysis<MachineBlockFrequencyInfo>()); - MLI = &getAnalysis<MachineLoopInfo>(); + MLI = &getAnalysis<MachineLoopInfoWrapperPass>().getLI(); TII = MF.getSubtarget().getInstrInfo(); TLI = MF.getSubtarget().getTargetLowering(); MPDT = nullptr; diff --git a/llvm/lib/CodeGen/MachineCombiner.cpp b/llvm/lib/CodeGen/MachineCombiner.cpp index 3bd3b8a..1a19e05 100644 --- a/llvm/lib/CodeGen/MachineCombiner.cpp +++ b/llvm/lib/CodeGen/MachineCombiner.cpp @@ -132,7 +132,7 @@ char &llvm::MachineCombinerID = MachineCombiner::ID; INITIALIZE_PASS_BEGIN(MachineCombiner, DEBUG_TYPE, "Machine InstCombiner", false, false) -INITIALIZE_PASS_DEPENDENCY(MachineLoopInfo) +INITIALIZE_PASS_DEPENDENCY(MachineLoopInfoWrapperPass) INITIALIZE_PASS_DEPENDENCY(MachineTraceMetrics) INITIALIZE_PASS_END(MachineCombiner, DEBUG_TYPE, "Machine InstCombiner", false, false) @@ -140,8 +140,8 @@ INITIALIZE_PASS_END(MachineCombiner, DEBUG_TYPE, "Machine InstCombiner", void MachineCombiner::getAnalysisUsage(AnalysisUsage &AU) const { AU.setPreservesCFG(); AU.addPreserved<MachineDominatorTreeWrapperPass>(); - AU.addRequired<MachineLoopInfo>(); - AU.addPreserved<MachineLoopInfo>(); + AU.addRequired<MachineLoopInfoWrapperPass>(); + AU.addPreserved<MachineLoopInfoWrapperPass>(); AU.addRequired<MachineTraceMetrics>(); AU.addPreserved<MachineTraceMetrics>(); AU.addRequired<LazyMachineBlockFrequencyInfoPass>(); @@ -726,7 +726,7 @@ bool MachineCombiner::runOnMachineFunction(MachineFunction &MF) { SchedModel = STI->getSchedModel(); TSchedModel.init(STI); MRI = &MF.getRegInfo(); - MLI = &getAnalysis<MachineLoopInfo>(); + MLI = &getAnalysis<MachineLoopInfoWrapperPass>().getLI(); Traces = &getAnalysis<MachineTraceMetrics>(); PSI = &getAnalysis<ProfileSummaryInfoWrapperPass>().getPSI(); MBFI = (PSI && PSI->hasProfileSummary()) ? diff --git a/llvm/lib/CodeGen/MachineLICM.cpp b/llvm/lib/CodeGen/MachineLICM.cpp index 287bd00..7a0c8ba 100644 --- a/llvm/lib/CodeGen/MachineLICM.cpp +++ b/llvm/lib/CodeGen/MachineLICM.cpp @@ -188,12 +188,12 @@ namespace { bool runOnMachineFunction(MachineFunction &MF) override; void getAnalysisUsage(AnalysisUsage &AU) const override { - AU.addRequired<MachineLoopInfo>(); + AU.addRequired<MachineLoopInfoWrapperPass>(); if (DisableHoistingToHotterBlocks != UseBFI::None) AU.addRequired<MachineBlockFrequencyInfo>(); AU.addRequired<MachineDominatorTreeWrapperPass>(); AU.addRequired<AAResultsWrapperPass>(); - AU.addPreserved<MachineLoopInfo>(); + AU.addPreserved<MachineLoopInfoWrapperPass>(); MachineFunctionPass::getAnalysisUsage(AU); } @@ -323,7 +323,7 @@ char &llvm::EarlyMachineLICMID = EarlyMachineLICM::ID; INITIALIZE_PASS_BEGIN(MachineLICM, DEBUG_TYPE, "Machine Loop Invariant Code Motion", false, false) -INITIALIZE_PASS_DEPENDENCY(MachineLoopInfo) +INITIALIZE_PASS_DEPENDENCY(MachineLoopInfoWrapperPass) INITIALIZE_PASS_DEPENDENCY(MachineBlockFrequencyInfo) INITIALIZE_PASS_DEPENDENCY(MachineDominatorTreeWrapperPass) INITIALIZE_PASS_DEPENDENCY(AAResultsWrapperPass) @@ -332,7 +332,7 @@ INITIALIZE_PASS_END(MachineLICM, DEBUG_TYPE, INITIALIZE_PASS_BEGIN(EarlyMachineLICM, "early-machinelicm", "Early Machine Loop Invariant Code Motion", false, false) -INITIALIZE_PASS_DEPENDENCY(MachineLoopInfo) +INITIALIZE_PASS_DEPENDENCY(MachineLoopInfoWrapperPass) INITIALIZE_PASS_DEPENDENCY(MachineBlockFrequencyInfo) INITIALIZE_PASS_DEPENDENCY(MachineDominatorTreeWrapperPass) INITIALIZE_PASS_DEPENDENCY(AAResultsWrapperPass) @@ -374,7 +374,7 @@ bool MachineLICMBase::runOnMachineFunction(MachineFunction &MF) { // Get our Loop information... if (DisableHoistingToHotterBlocks != UseBFI::None) MBFI = &getAnalysis<MachineBlockFrequencyInfo>(); - MLI = &getAnalysis<MachineLoopInfo>(); + MLI = &getAnalysis<MachineLoopInfoWrapperPass>().getLI(); DT = &getAnalysis<MachineDominatorTreeWrapperPass>().getDomTree(); AA = &getAnalysis<AAResultsWrapperPass>().getAAResults(); diff --git a/llvm/lib/CodeGen/MachineLoopInfo.cpp b/llvm/lib/CodeGen/MachineLoopInfo.cpp index 9fb1039..a03c008 100644 --- a/llvm/lib/CodeGen/MachineLoopInfo.cpp +++ b/llvm/lib/CodeGen/MachineLoopInfo.cpp @@ -30,29 +30,57 @@ using namespace llvm; template class llvm::LoopBase<MachineBasicBlock, MachineLoop>; template class llvm::LoopInfoBase<MachineBasicBlock, MachineLoop>; -char MachineLoopInfo::ID = 0; -MachineLoopInfo::MachineLoopInfo() : MachineFunctionPass(ID) { - initializeMachineLoopInfoPass(*PassRegistry::getPassRegistry()); +AnalysisKey MachineLoopAnalysis::Key; + +MachineLoopAnalysis::Result +MachineLoopAnalysis::run(MachineFunction &MF, + MachineFunctionAnalysisManager &MFAM) { + return MachineLoopInfo(MFAM.getResult<MachineDominatorTreeAnalysis>(MF)); +} + +PreservedAnalyses +MachineLoopPrinterPass::run(MachineFunction &MF, + MachineFunctionAnalysisManager &MFAM) { + OS << "Machine loop info for machine function '" << MF.getName() << "':\n"; + MFAM.getResult<MachineLoopAnalysis>(MF).print(OS); + return PreservedAnalyses::all(); } -INITIALIZE_PASS_BEGIN(MachineLoopInfo, "machine-loops", - "Machine Natural Loop Construction", true, true) + +char MachineLoopInfoWrapperPass::ID = 0; +MachineLoopInfoWrapperPass::MachineLoopInfoWrapperPass() + : MachineFunctionPass(ID) { + initializeMachineLoopInfoWrapperPassPass(*PassRegistry::getPassRegistry()); +} +INITIALIZE_PASS_BEGIN(MachineLoopInfoWrapperPass, "machine-loops", + "Machine Natural Loop Construction", true, true) INITIALIZE_PASS_DEPENDENCY(MachineDominatorTreeWrapperPass) -INITIALIZE_PASS_END(MachineLoopInfo, "machine-loops", - "Machine Natural Loop Construction", true, true) +INITIALIZE_PASS_END(MachineLoopInfoWrapperPass, "machine-loops", + "Machine Natural Loop Construction", true, true) -char &llvm::MachineLoopInfoID = MachineLoopInfo::ID; +char &llvm::MachineLoopInfoID = MachineLoopInfoWrapperPass::ID; -bool MachineLoopInfo::runOnMachineFunction(MachineFunction &) { - calculate(getAnalysis<MachineDominatorTreeWrapperPass>().getDomTree()); +bool MachineLoopInfoWrapperPass::runOnMachineFunction(MachineFunction &) { + LI.calculate(getAnalysis<MachineDominatorTreeWrapperPass>().getDomTree()); return false; } +bool MachineLoopInfo::invalidate( + MachineFunction &, const PreservedAnalyses &PA, + MachineFunctionAnalysisManager::Invalidator &) { + // Check whether the analysis, all analyses on functions, or the function's + // CFG have been preserved. + auto PAC = PA.getChecker<MachineLoopAnalysis>(); + return !PAC.preserved() && + !PAC.preservedSet<AllAnalysesOn<MachineFunction>>() && + !PAC.preservedSet<CFGAnalyses>(); +} + void MachineLoopInfo::calculate(MachineDominatorTree &MDT) { releaseMemory(); - LI.analyze(MDT.getBase()); + analyze(MDT.getBase()); } -void MachineLoopInfo::getAnalysisUsage(AnalysisUsage &AU) const { +void MachineLoopInfoWrapperPass::getAnalysisUsage(AnalysisUsage &AU) const { AU.setPreservesAll(); AU.addRequired<MachineDominatorTreeWrapperPass>(); MachineFunctionPass::getAnalysisUsage(AU); diff --git a/llvm/lib/CodeGen/MachinePipeliner.cpp b/llvm/lib/CodeGen/MachinePipeliner.cpp index 515c7f8..4460f1f 100644 --- a/llvm/lib/CodeGen/MachinePipeliner.cpp +++ b/llvm/lib/CodeGen/MachinePipeliner.cpp @@ -234,7 +234,7 @@ char &llvm::MachinePipelinerID = MachinePipeliner::ID; INITIALIZE_PASS_BEGIN(MachinePipeliner, DEBUG_TYPE, "Modulo Software Pipelining", false, false) INITIALIZE_PASS_DEPENDENCY(AAResultsWrapperPass) -INITIALIZE_PASS_DEPENDENCY(MachineLoopInfo) +INITIALIZE_PASS_DEPENDENCY(MachineLoopInfoWrapperPass) INITIALIZE_PASS_DEPENDENCY(MachineDominatorTreeWrapperPass) INITIALIZE_PASS_DEPENDENCY(LiveIntervals) INITIALIZE_PASS_END(MachinePipeliner, DEBUG_TYPE, @@ -263,7 +263,7 @@ bool MachinePipeliner::runOnMachineFunction(MachineFunction &mf) { return false; MF = &mf; - MLI = &getAnalysis<MachineLoopInfo>(); + MLI = &getAnalysis<MachineLoopInfoWrapperPass>().getLI(); MDT = &getAnalysis<MachineDominatorTreeWrapperPass>().getDomTree(); ORE = &getAnalysis<MachineOptimizationRemarkEmitterPass>().getORE(); TII = MF->getSubtarget().getInstrInfo(); @@ -499,7 +499,7 @@ bool MachinePipeliner::swingModuloScheduler(MachineLoop &L) { void MachinePipeliner::getAnalysisUsage(AnalysisUsage &AU) const { AU.addRequired<AAResultsWrapperPass>(); AU.addPreserved<AAResultsWrapperPass>(); - AU.addRequired<MachineLoopInfo>(); + AU.addRequired<MachineLoopInfoWrapperPass>(); AU.addRequired<MachineDominatorTreeWrapperPass>(); AU.addRequired<LiveIntervals>(); AU.addRequired<MachineOptimizationRemarkEmitterPass>(); diff --git a/llvm/lib/CodeGen/MachineScheduler.cpp b/llvm/lib/CodeGen/MachineScheduler.cpp index 4a6d5ed..84ba703 100644 --- a/llvm/lib/CodeGen/MachineScheduler.cpp +++ b/llvm/lib/CodeGen/MachineScheduler.cpp @@ -267,7 +267,7 @@ INITIALIZE_PASS_BEGIN(MachineScheduler, DEBUG_TYPE, "Machine Instruction Scheduler", false, false) INITIALIZE_PASS_DEPENDENCY(AAResultsWrapperPass) INITIALIZE_PASS_DEPENDENCY(MachineDominatorTreeWrapperPass) -INITIALIZE_PASS_DEPENDENCY(MachineLoopInfo) +INITIALIZE_PASS_DEPENDENCY(MachineLoopInfoWrapperPass) INITIALIZE_PASS_DEPENDENCY(SlotIndexes) INITIALIZE_PASS_DEPENDENCY(LiveIntervals) INITIALIZE_PASS_END(MachineScheduler, DEBUG_TYPE, @@ -280,7 +280,7 @@ MachineScheduler::MachineScheduler() : MachineSchedulerBase(ID) { void MachineScheduler::getAnalysisUsage(AnalysisUsage &AU) const { AU.setPreservesCFG(); AU.addRequired<MachineDominatorTreeWrapperPass>(); - AU.addRequired<MachineLoopInfo>(); + AU.addRequired<MachineLoopInfoWrapperPass>(); AU.addRequired<AAResultsWrapperPass>(); AU.addRequired<TargetPassConfig>(); AU.addRequired<SlotIndexes>(); @@ -297,7 +297,7 @@ char &llvm::PostMachineSchedulerID = PostMachineScheduler::ID; INITIALIZE_PASS_BEGIN(PostMachineScheduler, "postmisched", "PostRA Machine Instruction Scheduler", false, false) INITIALIZE_PASS_DEPENDENCY(MachineDominatorTreeWrapperPass) -INITIALIZE_PASS_DEPENDENCY(MachineLoopInfo) +INITIALIZE_PASS_DEPENDENCY(MachineLoopInfoWrapperPass) INITIALIZE_PASS_DEPENDENCY(AAResultsWrapperPass) INITIALIZE_PASS_END(PostMachineScheduler, "postmisched", "PostRA Machine Instruction Scheduler", false, false) @@ -309,7 +309,7 @@ PostMachineScheduler::PostMachineScheduler() : MachineSchedulerBase(ID) { void PostMachineScheduler::getAnalysisUsage(AnalysisUsage &AU) const { AU.setPreservesCFG(); AU.addRequired<MachineDominatorTreeWrapperPass>(); - AU.addRequired<MachineLoopInfo>(); + AU.addRequired<MachineLoopInfoWrapperPass>(); AU.addRequired<AAResultsWrapperPass>(); AU.addRequired<TargetPassConfig>(); MachineFunctionPass::getAnalysisUsage(AU); @@ -444,7 +444,7 @@ bool MachineScheduler::runOnMachineFunction(MachineFunction &mf) { // Initialize the context of the pass. MF = &mf; - MLI = &getAnalysis<MachineLoopInfo>(); + MLI = &getAnalysis<MachineLoopInfoWrapperPass>().getLI(); MDT = &getAnalysis<MachineDominatorTreeWrapperPass>().getDomTree(); PassConfig = &getAnalysis<TargetPassConfig>(); AA = &getAnalysis<AAResultsWrapperPass>().getAAResults(); @@ -491,7 +491,7 @@ bool PostMachineScheduler::runOnMachineFunction(MachineFunction &mf) { // Initialize the context of the pass. MF = &mf; - MLI = &getAnalysis<MachineLoopInfo>(); + MLI = &getAnalysis<MachineLoopInfoWrapperPass>().getLI(); PassConfig = &getAnalysis<TargetPassConfig>(); AA = &getAnalysis<AAResultsWrapperPass>().getAAResults(); diff --git a/llvm/lib/CodeGen/MachineSink.cpp b/llvm/lib/CodeGen/MachineSink.cpp index 4dabaab..83c2895 100644 --- a/llvm/lib/CodeGen/MachineSink.cpp +++ b/llvm/lib/CodeGen/MachineSink.cpp @@ -189,7 +189,7 @@ namespace { AU.addRequired<MachineCycleInfoWrapperPass>(); AU.addRequired<MachineBranchProbabilityInfoWrapperPass>(); AU.addPreserved<MachineCycleInfoWrapperPass>(); - AU.addPreserved<MachineLoopInfo>(); + AU.addPreserved<MachineLoopInfoWrapperPass>(); if (UseBlockFreqInfo) AU.addRequired<MachineBlockFrequencyInfo>(); AU.addRequired<TargetPassConfig>(); diff --git a/llvm/lib/CodeGen/MachineTraceMetrics.cpp b/llvm/lib/CodeGen/MachineTraceMetrics.cpp index 0f44777..bf3add0 100644 --- a/llvm/lib/CodeGen/MachineTraceMetrics.cpp +++ b/llvm/lib/CodeGen/MachineTraceMetrics.cpp @@ -47,7 +47,7 @@ char &llvm::MachineTraceMetricsID = MachineTraceMetrics::ID; INITIALIZE_PASS_BEGIN(MachineTraceMetrics, DEBUG_TYPE, "Machine Trace Metrics", false, true) INITIALIZE_PASS_DEPENDENCY(MachineBranchProbabilityInfoWrapperPass) -INITIALIZE_PASS_DEPENDENCY(MachineLoopInfo) +INITIALIZE_PASS_DEPENDENCY(MachineLoopInfoWrapperPass) INITIALIZE_PASS_END(MachineTraceMetrics, DEBUG_TYPE, "Machine Trace Metrics", false, true) @@ -58,7 +58,7 @@ MachineTraceMetrics::MachineTraceMetrics() : MachineFunctionPass(ID) { void MachineTraceMetrics::getAnalysisUsage(AnalysisUsage &AU) const { AU.setPreservesAll(); AU.addRequired<MachineBranchProbabilityInfoWrapperPass>(); - AU.addRequired<MachineLoopInfo>(); + AU.addRequired<MachineLoopInfoWrapperPass>(); MachineFunctionPass::getAnalysisUsage(AU); } @@ -68,7 +68,7 @@ bool MachineTraceMetrics::runOnMachineFunction(MachineFunction &Func) { TII = ST.getInstrInfo(); TRI = ST.getRegisterInfo(); MRI = &MF->getRegInfo(); - Loops = &getAnalysis<MachineLoopInfo>(); + Loops = &getAnalysis<MachineLoopInfoWrapperPass>().getLI(); SchedModel.init(&ST); BlockInfo.resize(MF->getNumBlockIDs()); ProcReleaseAtCycles.resize(MF->getNumBlockIDs() * diff --git a/llvm/lib/CodeGen/ModuloSchedule.cpp b/llvm/lib/CodeGen/ModuloSchedule.cpp index 0aed235..8b4a6fe 100644 --- a/llvm/lib/CodeGen/ModuloSchedule.cpp +++ b/llvm/lib/CodeGen/ModuloSchedule.cpp @@ -2763,7 +2763,7 @@ public: void runOnLoop(MachineFunction &MF, MachineLoop &L); void getAnalysisUsage(AnalysisUsage &AU) const override { - AU.addRequired<MachineLoopInfo>(); + AU.addRequired<MachineLoopInfoWrapperPass>(); AU.addRequired<LiveIntervals>(); MachineFunctionPass::getAnalysisUsage(AU); } @@ -2774,13 +2774,13 @@ char ModuloScheduleTest::ID = 0; INITIALIZE_PASS_BEGIN(ModuloScheduleTest, "modulo-schedule-test", "Modulo Schedule test pass", false, false) -INITIALIZE_PASS_DEPENDENCY(MachineLoopInfo) +INITIALIZE_PASS_DEPENDENCY(MachineLoopInfoWrapperPass) INITIALIZE_PASS_DEPENDENCY(LiveIntervals) INITIALIZE_PASS_END(ModuloScheduleTest, "modulo-schedule-test", "Modulo Schedule test pass", false, false) bool ModuloScheduleTest::runOnMachineFunction(MachineFunction &MF) { - MachineLoopInfo &MLI = getAnalysis<MachineLoopInfo>(); + MachineLoopInfo &MLI = getAnalysis<MachineLoopInfoWrapperPass>().getLI(); for (auto *L : MLI) { if (L->getTopBlock() != L->getBottomBlock()) continue; diff --git a/llvm/lib/CodeGen/PHIElimination.cpp b/llvm/lib/CodeGen/PHIElimination.cpp index 4fde4ec7..e5c4c71 100644 --- a/llvm/lib/CodeGen/PHIElimination.cpp +++ b/llvm/lib/CodeGen/PHIElimination.cpp @@ -141,7 +141,7 @@ void PHIElimination::getAnalysisUsage(AnalysisUsage &AU) const { AU.addPreserved<SlotIndexes>(); AU.addPreserved<LiveIntervals>(); AU.addPreserved<MachineDominatorTreeWrapperPass>(); - AU.addPreserved<MachineLoopInfo>(); + AU.addPreserved<MachineLoopInfoWrapperPass>(); MachineFunctionPass::getAnalysisUsage(AU); } @@ -183,7 +183,9 @@ bool PHIElimination::runOnMachineFunction(MachineFunction &MF) { } } - MachineLoopInfo *MLI = getAnalysisIfAvailable<MachineLoopInfo>(); + MachineLoopInfoWrapperPass *MLIWrapper = + getAnalysisIfAvailable<MachineLoopInfoWrapperPass>(); + MachineLoopInfo *MLI = MLIWrapper ? &MLIWrapper->getLI() : nullptr; for (auto &MBB : MF) Changed |= SplitPHIEdges(MF, MBB, MLI, (LV ? &LiveInSets : nullptr)); } diff --git a/llvm/lib/CodeGen/PeepholeOptimizer.cpp b/llvm/lib/CodeGen/PeepholeOptimizer.cpp index 2e078be..746ec0f 100644 --- a/llvm/lib/CodeGen/PeepholeOptimizer.cpp +++ b/llvm/lib/CodeGen/PeepholeOptimizer.cpp @@ -169,8 +169,8 @@ namespace { void getAnalysisUsage(AnalysisUsage &AU) const override { AU.setPreservesCFG(); MachineFunctionPass::getAnalysisUsage(AU); - AU.addRequired<MachineLoopInfo>(); - AU.addPreserved<MachineLoopInfo>(); + AU.addRequired<MachineLoopInfoWrapperPass>(); + AU.addPreserved<MachineLoopInfoWrapperPass>(); if (Aggressive) { AU.addRequired<MachineDominatorTreeWrapperPass>(); AU.addPreserved<MachineDominatorTreeWrapperPass>(); @@ -488,7 +488,7 @@ char &llvm::PeepholeOptimizerID = PeepholeOptimizer::ID; INITIALIZE_PASS_BEGIN(PeepholeOptimizer, DEBUG_TYPE, "Peephole Optimizations", false, false) INITIALIZE_PASS_DEPENDENCY(MachineDominatorTreeWrapperPass) -INITIALIZE_PASS_DEPENDENCY(MachineLoopInfo) +INITIALIZE_PASS_DEPENDENCY(MachineLoopInfoWrapperPass) INITIALIZE_PASS_END(PeepholeOptimizer, DEBUG_TYPE, "Peephole Optimizations", false, false) @@ -1671,7 +1671,7 @@ bool PeepholeOptimizer::runOnMachineFunction(MachineFunction &MF) { MRI = &MF.getRegInfo(); DT = Aggressive ? &getAnalysis<MachineDominatorTreeWrapperPass>().getDomTree() : nullptr; - MLI = &getAnalysis<MachineLoopInfo>(); + MLI = &getAnalysis<MachineLoopInfoWrapperPass>().getLI(); MF.setDelegate(this); bool Changed = false; diff --git a/llvm/lib/CodeGen/PostRASchedulerList.cpp b/llvm/lib/CodeGen/PostRASchedulerList.cpp index 8005050..2f7cfdd 100644 --- a/llvm/lib/CodeGen/PostRASchedulerList.cpp +++ b/llvm/lib/CodeGen/PostRASchedulerList.cpp @@ -87,8 +87,8 @@ namespace { AU.addRequired<TargetPassConfig>(); AU.addRequired<MachineDominatorTreeWrapperPass>(); AU.addPreserved<MachineDominatorTreeWrapperPass>(); - AU.addRequired<MachineLoopInfo>(); - AU.addPreserved<MachineLoopInfo>(); + AU.addRequired<MachineLoopInfoWrapperPass>(); + AU.addPreserved<MachineLoopInfoWrapperPass>(); MachineFunctionPass::getAnalysisUsage(AU); } @@ -279,7 +279,7 @@ bool PostRAScheduler::runOnMachineFunction(MachineFunction &Fn) { return false; TII = Fn.getSubtarget().getInstrInfo(); - MachineLoopInfo &MLI = getAnalysis<MachineLoopInfo>(); + MachineLoopInfo &MLI = getAnalysis<MachineLoopInfoWrapperPass>().getLI(); AliasAnalysis *AA = &getAnalysis<AAResultsWrapperPass>().getAAResults(); TargetPassConfig *PassConfig = &getAnalysis<TargetPassConfig>(); diff --git a/llvm/lib/CodeGen/PrologEpilogInserter.cpp b/llvm/lib/CodeGen/PrologEpilogInserter.cpp index ca54e88..3db5e17 100644 --- a/llvm/lib/CodeGen/PrologEpilogInserter.cpp +++ b/llvm/lib/CodeGen/PrologEpilogInserter.cpp @@ -150,7 +150,7 @@ char &llvm::PrologEpilogCodeInserterID = PEI::ID; INITIALIZE_PASS_BEGIN(PEI, DEBUG_TYPE, "Prologue/Epilogue Insertion", false, false) -INITIALIZE_PASS_DEPENDENCY(MachineLoopInfo) +INITIALIZE_PASS_DEPENDENCY(MachineLoopInfoWrapperPass) INITIALIZE_PASS_DEPENDENCY(MachineDominatorTreeWrapperPass) INITIALIZE_PASS_DEPENDENCY(MachineOptimizationRemarkEmitterPass) INITIALIZE_PASS_END(PEI, DEBUG_TYPE, @@ -166,7 +166,7 @@ STATISTIC(NumBytesStackSpace, void PEI::getAnalysisUsage(AnalysisUsage &AU) const { AU.setPreservesCFG(); - AU.addPreserved<MachineLoopInfo>(); + AU.addPreserved<MachineLoopInfoWrapperPass>(); AU.addPreserved<MachineDominatorTreeWrapperPass>(); AU.addRequired<MachineOptimizationRemarkEmitterPass>(); MachineFunctionPass::getAnalysisUsage(AU); diff --git a/llvm/lib/CodeGen/RegAllocBasic.cpp b/llvm/lib/CodeGen/RegAllocBasic.cpp index f465c63..2062334 100644 --- a/llvm/lib/CodeGen/RegAllocBasic.cpp +++ b/llvm/lib/CodeGen/RegAllocBasic.cpp @@ -137,7 +137,7 @@ INITIALIZE_PASS_DEPENDENCY(MachineScheduler) INITIALIZE_PASS_DEPENDENCY(LiveStacks) INITIALIZE_PASS_DEPENDENCY(AAResultsWrapperPass) INITIALIZE_PASS_DEPENDENCY(MachineDominatorTreeWrapperPass) -INITIALIZE_PASS_DEPENDENCY(MachineLoopInfo) +INITIALIZE_PASS_DEPENDENCY(MachineLoopInfoWrapperPass) INITIALIZE_PASS_DEPENDENCY(VirtRegMap) INITIALIZE_PASS_DEPENDENCY(LiveRegMatrix) INITIALIZE_PASS_END(RABasic, "regallocbasic", "Basic Register Allocator", false, @@ -188,8 +188,8 @@ void RABasic::getAnalysisUsage(AnalysisUsage &AU) const { AU.addPreserved<MachineBlockFrequencyInfo>(); AU.addRequiredID(MachineDominatorsID); AU.addPreservedID(MachineDominatorsID); - AU.addRequired<MachineLoopInfo>(); - AU.addPreserved<MachineLoopInfo>(); + AU.addRequired<MachineLoopInfoWrapperPass>(); + AU.addPreserved<MachineLoopInfoWrapperPass>(); AU.addRequired<VirtRegMap>(); AU.addPreserved<VirtRegMap>(); AU.addRequired<LiveRegMatrix>(); @@ -312,7 +312,8 @@ bool RABasic::runOnMachineFunction(MachineFunction &mf) { RegAllocBase::init(getAnalysis<VirtRegMap>(), getAnalysis<LiveIntervals>(), getAnalysis<LiveRegMatrix>()); - VirtRegAuxInfo VRAI(*MF, *LIS, *VRM, getAnalysis<MachineLoopInfo>(), + VirtRegAuxInfo VRAI(*MF, *LIS, *VRM, + getAnalysis<MachineLoopInfoWrapperPass>().getLI(), getAnalysis<MachineBlockFrequencyInfo>()); VRAI.calculateSpillWeightsAndHints(); diff --git a/llvm/lib/CodeGen/RegAllocGreedy.cpp b/llvm/lib/CodeGen/RegAllocGreedy.cpp index 19c1ee2..b79b0e5 100644 --- a/llvm/lib/CodeGen/RegAllocGreedy.cpp +++ b/llvm/lib/CodeGen/RegAllocGreedy.cpp @@ -161,7 +161,7 @@ INITIALIZE_PASS_DEPENDENCY(RegisterCoalescer) INITIALIZE_PASS_DEPENDENCY(MachineScheduler) INITIALIZE_PASS_DEPENDENCY(LiveStacks) INITIALIZE_PASS_DEPENDENCY(MachineDominatorTreeWrapperPass) -INITIALIZE_PASS_DEPENDENCY(MachineLoopInfo) +INITIALIZE_PASS_DEPENDENCY(MachineLoopInfoWrapperPass) INITIALIZE_PASS_DEPENDENCY(VirtRegMap) INITIALIZE_PASS_DEPENDENCY(LiveRegMatrix) INITIALIZE_PASS_DEPENDENCY(EdgeBundles) @@ -215,8 +215,8 @@ void RAGreedy::getAnalysisUsage(AnalysisUsage &AU) const { AU.addPreserved<LiveStacks>(); AU.addRequired<MachineDominatorTreeWrapperPass>(); AU.addPreserved<MachineDominatorTreeWrapperPass>(); - AU.addRequired<MachineLoopInfo>(); - AU.addPreserved<MachineLoopInfo>(); + AU.addRequired<MachineLoopInfoWrapperPass>(); + AU.addPreserved<MachineLoopInfoWrapperPass>(); AU.addRequired<VirtRegMap>(); AU.addPreserved<VirtRegMap>(); AU.addRequired<LiveRegMatrix>(); @@ -2731,7 +2731,7 @@ bool RAGreedy::runOnMachineFunction(MachineFunction &mf) { MBFI = &getAnalysis<MachineBlockFrequencyInfo>(); DomTree = &getAnalysis<MachineDominatorTreeWrapperPass>().getDomTree(); ORE = &getAnalysis<MachineOptimizationRemarkEmitterPass>().getORE(); - Loops = &getAnalysis<MachineLoopInfo>(); + Loops = &getAnalysis<MachineLoopInfoWrapperPass>().getLI(); Bundles = &getAnalysis<EdgeBundles>(); SpillPlacer = &getAnalysis<SpillPlacement>(); DebugVars = &getAnalysis<LiveDebugVariables>(); diff --git a/llvm/lib/CodeGen/RegAllocPBQP.cpp b/llvm/lib/CodeGen/RegAllocPBQP.cpp index 88ba84306..293c01b 100644 --- a/llvm/lib/CodeGen/RegAllocPBQP.cpp +++ b/llvm/lib/CodeGen/RegAllocPBQP.cpp @@ -555,8 +555,8 @@ void RegAllocPBQP::getAnalysisUsage(AnalysisUsage &au) const { au.addPreserved<LiveStacks>(); au.addRequired<MachineBlockFrequencyInfo>(); au.addPreserved<MachineBlockFrequencyInfo>(); - au.addRequired<MachineLoopInfo>(); - au.addPreserved<MachineLoopInfo>(); + au.addRequired<MachineLoopInfoWrapperPass>(); + au.addPreserved<MachineLoopInfoWrapperPass>(); au.addRequired<MachineDominatorTreeWrapperPass>(); au.addPreserved<MachineDominatorTreeWrapperPass>(); au.addRequired<VirtRegMap>(); @@ -797,15 +797,16 @@ bool RegAllocPBQP::runOnMachineFunction(MachineFunction &MF) { VirtRegMap &VRM = getAnalysis<VirtRegMap>(); - PBQPVirtRegAuxInfo VRAI(MF, LIS, VRM, getAnalysis<MachineLoopInfo>(), MBFI); + PBQPVirtRegAuxInfo VRAI( + MF, LIS, VRM, getAnalysis<MachineLoopInfoWrapperPass>().getLI(), MBFI); VRAI.calculateSpillWeightsAndHints(); // FIXME: we create DefaultVRAI here to match existing behavior pre-passing // the VRAI through the spiller to the live range editor. However, it probably // makes more sense to pass the PBQP VRAI. The existing behavior had // LiveRangeEdit make its own VirtRegAuxInfo object. - VirtRegAuxInfo DefaultVRAI(MF, LIS, VRM, getAnalysis<MachineLoopInfo>(), - MBFI); + VirtRegAuxInfo DefaultVRAI( + MF, LIS, VRM, getAnalysis<MachineLoopInfoWrapperPass>().getLI(), MBFI); std::unique_ptr<Spiller> VRegSpiller( createInlineSpiller(*this, MF, VRM, DefaultVRAI)); diff --git a/llvm/lib/CodeGen/RegisterCoalescer.cpp b/llvm/lib/CodeGen/RegisterCoalescer.cpp index 9f4f238..7c7fb8f 100644 --- a/llvm/lib/CodeGen/RegisterCoalescer.cpp +++ b/llvm/lib/CodeGen/RegisterCoalescer.cpp @@ -408,7 +408,7 @@ INITIALIZE_PASS_BEGIN(RegisterCoalescer, "register-coalescer", "Register Coalescer", false, false) INITIALIZE_PASS_DEPENDENCY(LiveIntervals) INITIALIZE_PASS_DEPENDENCY(SlotIndexes) -INITIALIZE_PASS_DEPENDENCY(MachineLoopInfo) +INITIALIZE_PASS_DEPENDENCY(MachineLoopInfoWrapperPass) INITIALIZE_PASS_DEPENDENCY(AAResultsWrapperPass) INITIALIZE_PASS_END(RegisterCoalescer, "register-coalescer", "Register Coalescer", false, false) @@ -591,8 +591,8 @@ void RegisterCoalescer::getAnalysisUsage(AnalysisUsage &AU) const { AU.addRequired<LiveIntervals>(); AU.addPreserved<LiveIntervals>(); AU.addPreserved<SlotIndexes>(); - AU.addRequired<MachineLoopInfo>(); - AU.addPreserved<MachineLoopInfo>(); + AU.addRequired<MachineLoopInfoWrapperPass>(); + AU.addPreserved<MachineLoopInfoWrapperPass>(); AU.addPreservedID(MachineDominatorsID); MachineFunctionPass::getAnalysisUsage(AU); } @@ -4208,7 +4208,7 @@ bool RegisterCoalescer::runOnMachineFunction(MachineFunction &fn) { TII = STI.getInstrInfo(); LIS = &getAnalysis<LiveIntervals>(); AA = &getAnalysis<AAResultsWrapperPass>().getAAResults(); - Loops = &getAnalysis<MachineLoopInfo>(); + Loops = &getAnalysis<MachineLoopInfoWrapperPass>().getLI(); if (EnableGlobalCopies == cl::BOU_UNSET) JoinGlobalCopies = STI.enableJoinGlobalCopies(); else diff --git a/llvm/lib/CodeGen/ShrinkWrap.cpp b/llvm/lib/CodeGen/ShrinkWrap.cpp index eb37016..28b2bec 100644 --- a/llvm/lib/CodeGen/ShrinkWrap.cpp +++ b/llvm/lib/CodeGen/ShrinkWrap.cpp @@ -230,7 +230,7 @@ class ShrinkWrap : public MachineFunctionPass { Save = nullptr; Restore = nullptr; MBFI = &getAnalysis<MachineBlockFrequencyInfo>(); - MLI = &getAnalysis<MachineLoopInfo>(); + MLI = &getAnalysis<MachineLoopInfoWrapperPass>().getLI(); ORE = &getAnalysis<MachineOptimizationRemarkEmitterPass>().getORE(); EntryFreq = MBFI->getEntryFreq(); const TargetSubtargetInfo &Subtarget = MF.getSubtarget(); @@ -264,7 +264,7 @@ public: AU.addRequired<MachineBlockFrequencyInfo>(); AU.addRequired<MachineDominatorTreeWrapperPass>(); AU.addRequired<MachinePostDominatorTreeWrapperPass>(); - AU.addRequired<MachineLoopInfo>(); + AU.addRequired<MachineLoopInfoWrapperPass>(); AU.addRequired<MachineOptimizationRemarkEmitterPass>(); MachineFunctionPass::getAnalysisUsage(AU); } @@ -291,7 +291,7 @@ INITIALIZE_PASS_BEGIN(ShrinkWrap, DEBUG_TYPE, "Shrink Wrap Pass", false, false) INITIALIZE_PASS_DEPENDENCY(MachineBlockFrequencyInfo) INITIALIZE_PASS_DEPENDENCY(MachineDominatorTreeWrapperPass) INITIALIZE_PASS_DEPENDENCY(MachinePostDominatorTreeWrapperPass) -INITIALIZE_PASS_DEPENDENCY(MachineLoopInfo) +INITIALIZE_PASS_DEPENDENCY(MachineLoopInfoWrapperPass) INITIALIZE_PASS_DEPENDENCY(MachineOptimizationRemarkEmitterPass) INITIALIZE_PASS_END(ShrinkWrap, DEBUG_TYPE, "Shrink Wrap Pass", false, false) diff --git a/llvm/lib/CodeGen/StackSlotColoring.cpp b/llvm/lib/CodeGen/StackSlotColoring.cpp index a24e347..5f039ea 100644 --- a/llvm/lib/CodeGen/StackSlotColoring.cpp +++ b/llvm/lib/CodeGen/StackSlotColoring.cpp @@ -187,7 +187,7 @@ INITIALIZE_PASS_BEGIN(StackSlotColoring, DEBUG_TYPE, "Stack Slot Coloring", false, false) INITIALIZE_PASS_DEPENDENCY(SlotIndexes) INITIALIZE_PASS_DEPENDENCY(LiveStacks) -INITIALIZE_PASS_DEPENDENCY(MachineLoopInfo) +INITIALIZE_PASS_DEPENDENCY(MachineLoopInfoWrapperPass) INITIALIZE_PASS_END(StackSlotColoring, DEBUG_TYPE, "Stack Slot Coloring", false, false) diff --git a/llvm/lib/CodeGen/UnreachableBlockElim.cpp b/llvm/lib/CodeGen/UnreachableBlockElim.cpp index 4cf0252..8194f3c 100644 --- a/llvm/lib/CodeGen/UnreachableBlockElim.cpp +++ b/llvm/lib/CodeGen/UnreachableBlockElim.cpp @@ -89,7 +89,7 @@ INITIALIZE_PASS(UnreachableMachineBlockElim, "unreachable-mbb-elimination", char &llvm::UnreachableMachineBlockElimID = UnreachableMachineBlockElim::ID; void UnreachableMachineBlockElim::getAnalysisUsage(AnalysisUsage &AU) const { - AU.addPreserved<MachineLoopInfo>(); + AU.addPreserved<MachineLoopInfoWrapperPass>(); AU.addPreserved<MachineDominatorTreeWrapperPass>(); MachineFunctionPass::getAnalysisUsage(AU); } @@ -101,7 +101,9 @@ bool UnreachableMachineBlockElim::runOnMachineFunction(MachineFunction &F) { MachineDominatorTreeWrapperPass *MDTWrapper = getAnalysisIfAvailable<MachineDominatorTreeWrapperPass>(); MachineDominatorTree *MDT = MDTWrapper ? &MDTWrapper->getDomTree() : nullptr; - MachineLoopInfo *MLI = getAnalysisIfAvailable<MachineLoopInfo>(); + MachineLoopInfoWrapperPass *MLIWrapper = + getAnalysisIfAvailable<MachineLoopInfoWrapperPass>(); + MachineLoopInfo *MLI = MLIWrapper ? &MLIWrapper->getLI() : nullptr; // Mark all reachable blocks. for (MachineBasicBlock *BB : depth_first_ext(&F, Reachable)) diff --git a/llvm/lib/CodeGen/XRayInstrumentation.cpp b/llvm/lib/CodeGen/XRayInstrumentation.cpp index a74362e..d7cc5d5 100644 --- a/llvm/lib/CodeGen/XRayInstrumentation.cpp +++ b/llvm/lib/CodeGen/XRayInstrumentation.cpp @@ -52,7 +52,7 @@ struct XRayInstrumentation : public MachineFunctionPass { void getAnalysisUsage(AnalysisUsage &AU) const override { AU.setPreservesCFG(); - AU.addPreserved<MachineLoopInfo>(); + AU.addPreserved<MachineLoopInfoWrapperPass>(); AU.addPreserved<MachineDominatorTreeWrapperPass>(); MachineFunctionPass::getAnalysisUsage(AU); } @@ -180,10 +180,11 @@ bool XRayInstrumentation::runOnMachineFunction(MachineFunction &MF) { } // Get MachineLoopInfo or compute it on the fly if it's unavailable - auto *MLI = getAnalysisIfAvailable<MachineLoopInfo>(); + auto *MLIWrapper = getAnalysisIfAvailable<MachineLoopInfoWrapperPass>(); + auto *MLI = MLIWrapper ? &MLIWrapper->getLI() : nullptr; MachineLoopInfo ComputedMLI; if (!MLI) { - ComputedMLI.getBase().analyze(MDT->getBase()); + ComputedMLI.analyze(MDT->getBase()); MLI = &ComputedMLI; } @@ -266,6 +267,6 @@ char XRayInstrumentation::ID = 0; char &llvm::XRayInstrumentationID = XRayInstrumentation::ID; INITIALIZE_PASS_BEGIN(XRayInstrumentation, "xray-instrumentation", "Insert XRay ops", false, false) -INITIALIZE_PASS_DEPENDENCY(MachineLoopInfo) +INITIALIZE_PASS_DEPENDENCY(MachineLoopInfoWrapperPass) INITIALIZE_PASS_END(XRayInstrumentation, "xray-instrumentation", "Insert XRay ops", false, false) |