diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index ef61bcb605eb..a5dffdb53ccf 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -244,7 +244,6 @@ const MCSection *AsmPrinter::getCurrentSection() const { void AsmPrinter::getAnalysisUsage(AnalysisUsage &AU) const { AU.setPreservesAll(); MachineFunctionPass::getAnalysisUsage(AU); - AU.addRequired(); AU.addRequired(); AU.addRequired(); } @@ -306,14 +305,14 @@ bool AsmPrinter::doInitialization(Module &M) { } if (MAI->doesSupportDebugInformation()) { - bool EmitCodeView = MMI->getModule()->getCodeViewFlag(); + bool EmitCodeView = M.getCodeViewFlag(); if (EmitCodeView && TM.getTargetTriple().isOSWindows()) { Handlers.emplace_back(std::make_unique(this), DbgTimerName, DbgTimerDescription, CodeViewLineTablesGroupName, CodeViewLineTablesGroupDescription); } - if (!EmitCodeView || MMI->getModule()->getDwarfVersion()) { + if (!EmitCodeView || M.getDwarfVersion()) { DD = new DwarfDebug(this, &M); DD->beginModule(); Handlers.emplace_back(std::unique_ptr(DD), DbgTimerName, @@ -376,8 +375,7 @@ bool AsmPrinter::doInitialization(Module &M) { DWARFGroupDescription); // Emit tables for any value of cfguard flag (i.e. cfguard=1 or cfguard=2). - if (mdconst::extract_or_null( - MMI->getModule()->getModuleFlag("cfguard"))) + if (mdconst::extract_or_null(M.getModuleFlag("cfguard"))) Handlers.emplace_back(std::make_unique(this), CFGuardName, CFGuardDescription, DWARFGroupName, DWARFGroupDescription); @@ -1051,9 +1049,9 @@ void AsmPrinter::emitStackSizeSection(const MachineFunction &MF) { OutStreamer->PopSection(); } -static bool needFuncLabelsForEHOrDebugInfo(const MachineFunction &MF, - MachineModuleInfo *MMI) { - if (!MF.getLandingPads().empty() || MF.hasEHFunclets() || MMI->hasDebugInfo()) +static bool needFuncLabelsForEHOrDebugInfo(const MachineFunction &MF) { + MachineModuleInfo &MMI = MF.getMMI(); + if (!MF.getLandingPads().empty() || MF.hasEHFunclets() || MMI.hasDebugInfo()) return true; // We might emit an EH table that uses function begin and end labels even if @@ -1261,7 +1259,7 @@ void AsmPrinter::emitFunctionBody() { // Emit target-specific gunk after the function body. emitFunctionBodyEnd(); - if (needFuncLabelsForEHOrDebugInfo(*MF, MMI) || + if (needFuncLabelsForEHOrDebugInfo(*MF) || MAI->hasDotTypeDotSizeDirective()) { // Create a symbol for the end of function. CurrentFnEnd = createTempSymbol("func_end"); @@ -1789,7 +1787,7 @@ void AsmPrinter::SetupMachineFunction(MachineFunction &MF) { if (F.hasFnAttribute("patchable-function-entry") || F.hasFnAttribute("function-instrument") || F.hasFnAttribute("xray-instruction-threshold") || - needFuncLabelsForEHOrDebugInfo(MF, MMI) || NeedsLocalForSize || + needFuncLabelsForEHOrDebugInfo(MF) || NeedsLocalForSize || MF.getTarget().Options.EmitStackSizeSection) { CurrentFnBegin = createTempSymbol("func_begin"); if (NeedsLocalForSize) diff --git a/llvm/lib/CodeGen/BBSectionsPrepare.cpp b/llvm/lib/CodeGen/BBSectionsPrepare.cpp index 5f92689c5e42..a35c4d813acc 100644 --- a/llvm/lib/CodeGen/BBSectionsPrepare.cpp +++ b/llvm/lib/CodeGen/BBSectionsPrepare.cpp @@ -448,7 +448,7 @@ bool BBSectionsPrepare::doInitialization(Module &M) { void BBSectionsPrepare::getAnalysisUsage(AnalysisUsage &AU) const { AU.setPreservesAll(); - AU.addRequired(); + MachineFunctionPass::getAnalysisUsage(AU); } MachineFunctionPass * diff --git a/llvm/lib/CodeGen/BranchFolding.cpp b/llvm/lib/CodeGen/BranchFolding.cpp index e7906626bbaa..022689c94a3e 100644 --- a/llvm/lib/CodeGen/BranchFolding.cpp +++ b/llvm/lib/CodeGen/BranchFolding.cpp @@ -135,10 +135,8 @@ bool BranchFolderPass::runOnMachineFunction(MachineFunction &MF) { BranchFolder Folder(EnableTailMerge, /*CommonHoist=*/true, MBBFreqInfo, getAnalysis(), &getAnalysis().getPSI()); - auto *MMIWP = getAnalysisIfAvailable(); - return Folder.OptimizeFunction( - MF, MF.getSubtarget().getInstrInfo(), MF.getSubtarget().getRegisterInfo(), - MMIWP ? &MMIWP->getMMI() : nullptr); + return Folder.OptimizeFunction(MF, MF.getSubtarget().getInstrInfo(), + MF.getSubtarget().getRegisterInfo()); } BranchFolder::BranchFolder(bool defaultEnableTailMerge, bool CommonHoist, @@ -184,7 +182,6 @@ void BranchFolder::RemoveDeadBlock(MachineBasicBlock *MBB) { bool BranchFolder::OptimizeFunction(MachineFunction &MF, const TargetInstrInfo *tii, const TargetRegisterInfo *tri, - MachineModuleInfo *mmi, MachineLoopInfo *mli, bool AfterPlacement) { if (!tii) return false; @@ -194,7 +191,6 @@ bool BranchFolder::OptimizeFunction(MachineFunction &MF, AfterBlockPlacement = AfterPlacement; TII = tii; TRI = tri; - MMI = mmi; MLI = mli; this->MRI = &MRI; diff --git a/llvm/lib/CodeGen/BranchFolding.h b/llvm/lib/CodeGen/BranchFolding.h index 56c14418ec34..49c6bcae2db4 100644 --- a/llvm/lib/CodeGen/BranchFolding.h +++ b/llvm/lib/CodeGen/BranchFolding.h @@ -45,7 +45,7 @@ class TargetRegisterInfo; /// given function. Block placement changes the layout and may create new /// tail merging opportunities. bool OptimizeFunction(MachineFunction &MF, const TargetInstrInfo *tii, - const TargetRegisterInfo *tri, MachineModuleInfo *mmi, + const TargetRegisterInfo *tri, MachineLoopInfo *mli = nullptr, bool AfterPlacement = false); @@ -124,7 +124,6 @@ class TargetRegisterInfo; const TargetInstrInfo *TII; const MachineRegisterInfo *MRI; const TargetRegisterInfo *TRI; - MachineModuleInfo *MMI; MachineLoopInfo *MLI; LivePhysRegs LiveRegs; diff --git a/llvm/lib/CodeGen/GCRootLowering.cpp b/llvm/lib/CodeGen/GCRootLowering.cpp index 5aff2d79435f..c6730aa6b00d 100644 --- a/llvm/lib/CodeGen/GCRootLowering.cpp +++ b/llvm/lib/CodeGen/GCRootLowering.cpp @@ -57,7 +57,6 @@ public: /// GCMetadata record for each function. class GCMachineCodeAnalysis : public MachineFunctionPass { GCFunctionInfo *FI; - MachineModuleInfo *MMI; const TargetInstrInfo *TII; void FindSafePoints(MachineFunction &MF); @@ -249,7 +248,6 @@ GCMachineCodeAnalysis::GCMachineCodeAnalysis() : MachineFunctionPass(ID) {} void GCMachineCodeAnalysis::getAnalysisUsage(AnalysisUsage &AU) const { MachineFunctionPass::getAnalysisUsage(AU); AU.setPreservesAll(); - AU.addRequired(); AU.addRequired(); } @@ -310,7 +308,6 @@ bool GCMachineCodeAnalysis::runOnMachineFunction(MachineFunction &MF) { return false; FI = &getAnalysis().getFunctionInfo(MF.getFunction()); - MMI = &getAnalysis().getMMI(); TII = MF.getSubtarget().getInstrInfo(); // Find the size of the stack frame. There may be no correct static frame diff --git a/llvm/lib/CodeGen/IfConversion.cpp b/llvm/lib/CodeGen/IfConversion.cpp index a3cace837eb9..1a5c5d685017 100644 --- a/llvm/lib/CodeGen/IfConversion.cpp +++ b/llvm/lib/CodeGen/IfConversion.cpp @@ -463,10 +463,7 @@ bool IfConverter::runOnMachineFunction(MachineFunction &MF) { if (!PreRegAlloc) { // Tail merge tend to expose more if-conversion opportunities. BranchFolder BF(true, false, MBFI, *MBPI, PSI); - auto *MMIWP = getAnalysisIfAvailable(); - BFChange = BF.OptimizeFunction( - MF, TII, ST.getRegisterInfo(), - MMIWP ? &MMIWP->getMMI() : nullptr); + BFChange = BF.OptimizeFunction(MF, TII, ST.getRegisterInfo()); } LLVM_DEBUG(dbgs() << "\nIfcvt: function (" << ++FnNum << ") \'" @@ -605,10 +602,7 @@ bool IfConverter::runOnMachineFunction(MachineFunction &MF) { if (MadeChange && IfCvtBranchFold) { BranchFolder BF(false, false, MBFI, *MBPI, PSI); - auto *MMIWP = getAnalysisIfAvailable(); - BF.OptimizeFunction( - MF, TII, MF.getSubtarget().getRegisterInfo(), - MMIWP ? &MMIWP->getMMI() : nullptr); + BF.OptimizeFunction(MF, TII, MF.getSubtarget().getRegisterInfo()); } MadeChange |= BFChange; diff --git a/llvm/lib/CodeGen/MachineBlockPlacement.cpp b/llvm/lib/CodeGen/MachineBlockPlacement.cpp index 229e23de1e53..783d22fafee9 100644 --- a/llvm/lib/CodeGen/MachineBlockPlacement.cpp +++ b/llvm/lib/CodeGen/MachineBlockPlacement.cpp @@ -3329,9 +3329,7 @@ bool MachineBlockPlacement::runOnMachineFunction(MachineFunction &MF) { BranchFolder BF(/*EnableTailMerge=*/true, /*CommonHoist=*/false, *MBFI, *MBPI, PSI, TailMergeSize); - auto *MMIWP = getAnalysisIfAvailable(); - if (BF.OptimizeFunction(MF, TII, MF.getSubtarget().getRegisterInfo(), - MMIWP ? &MMIWP->getMMI() : nullptr, MLI, + if (BF.OptimizeFunction(MF, TII, MF.getSubtarget().getRegisterInfo(), MLI, /*AfterPlacement=*/true)) { // Redo the layout if tail merging creates/removes/moves blocks. BlockToChain.clear(); diff --git a/llvm/lib/CodeGen/UnreachableBlockElim.cpp b/llvm/lib/CodeGen/UnreachableBlockElim.cpp index dc40cb081f6c..f5dc589a98cb 100644 --- a/llvm/lib/CodeGen/UnreachableBlockElim.cpp +++ b/llvm/lib/CodeGen/UnreachableBlockElim.cpp @@ -81,7 +81,7 @@ namespace { class UnreachableMachineBlockElim : public MachineFunctionPass { bool runOnMachineFunction(MachineFunction &F) override; void getAnalysisUsage(AnalysisUsage &AU) const override; - MachineModuleInfo *MMI; + public: static char ID; // Pass identification, replacement for typeid UnreachableMachineBlockElim() : MachineFunctionPass(ID) {} @@ -104,8 +104,6 @@ bool UnreachableMachineBlockElim::runOnMachineFunction(MachineFunction &F) { df_iterator_default_set Reachable; bool ModifiedPHI = false; - auto *MMIWP = getAnalysisIfAvailable(); - MMI = MMIWP ? &MMIWP->getMMI() : nullptr; MachineDominatorTree *MDT = getAnalysisIfAvailable(); MachineLoopInfo *MLI = getAnalysisIfAvailable(); diff --git a/llvm/lib/Target/AArch64/AArch64SLSHardening.cpp b/llvm/lib/Target/AArch64/AArch64SLSHardening.cpp index 0baf22a51c92..cb4dc8462f68 100644 --- a/llvm/lib/Target/AArch64/AArch64SLSHardening.cpp +++ b/llvm/lib/Target/AArch64/AArch64SLSHardening.cpp @@ -403,12 +403,6 @@ public: bool doInitialization(Module &M) override; bool runOnMachineFunction(MachineFunction &MF) override; - void getAnalysisUsage(AnalysisUsage &AU) const override { - MachineFunctionPass::getAnalysisUsage(AU); - AU.addRequired(); - AU.addPreserved(); - } - private: std::tuple TIs; diff --git a/llvm/lib/Target/X86/X86IndirectThunks.cpp b/llvm/lib/Target/X86/X86IndirectThunks.cpp index 226af7ba1bc1..828887d96129 100644 --- a/llvm/lib/Target/X86/X86IndirectThunks.cpp +++ b/llvm/lib/Target/X86/X86IndirectThunks.cpp @@ -110,12 +110,6 @@ public: bool doInitialization(Module &M) override; bool runOnMachineFunction(MachineFunction &MF) override; - void getAnalysisUsage(AnalysisUsage &AU) const override { - MachineFunctionPass::getAnalysisUsage(AU); - AU.addRequired(); - AU.addPreserved(); - } - private: std::tuple TIs; diff --git a/llvm/lib/Target/X86/X86InsertPrefetch.cpp b/llvm/lib/Target/X86/X86InsertPrefetch.cpp index 2b1e3f23efd7..53925bbfd72f 100644 --- a/llvm/lib/Target/X86/X86InsertPrefetch.cpp +++ b/llvm/lib/Target/X86/X86InsertPrefetch.cpp @@ -173,7 +173,7 @@ bool X86InsertPrefetch::doInitialization(Module &M) { void X86InsertPrefetch::getAnalysisUsage(AnalysisUsage &AU) const { AU.setPreservesAll(); - AU.addRequired(); + MachineFunctionPass::getAnalysisUsage(AU); } bool X86InsertPrefetch::runOnMachineFunction(MachineFunction &MF) {