Skip to content

Commit 78c69a0

Browse files
author
Yuanfang Chen
committed
[NFC] Clean up uses of MachineModuleInfoWrapperPass
1 parent 0f6afd9 commit 78c69a0

11 files changed

+17
-49
lines changed

llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,6 @@ const MCSection *AsmPrinter::getCurrentSection() const {
244244
void AsmPrinter::getAnalysisUsage(AnalysisUsage &AU) const {
245245
AU.setPreservesAll();
246246
MachineFunctionPass::getAnalysisUsage(AU);
247-
AU.addRequired<MachineModuleInfoWrapperPass>();
248247
AU.addRequired<MachineOptimizationRemarkEmitterPass>();
249248
AU.addRequired<GCModuleInfo>();
250249
}
@@ -306,14 +305,14 @@ bool AsmPrinter::doInitialization(Module &M) {
306305
}
307306

308307
if (MAI->doesSupportDebugInformation()) {
309-
bool EmitCodeView = MMI->getModule()->getCodeViewFlag();
308+
bool EmitCodeView = M.getCodeViewFlag();
310309
if (EmitCodeView && TM.getTargetTriple().isOSWindows()) {
311310
Handlers.emplace_back(std::make_unique<CodeViewDebug>(this),
312311
DbgTimerName, DbgTimerDescription,
313312
CodeViewLineTablesGroupName,
314313
CodeViewLineTablesGroupDescription);
315314
}
316-
if (!EmitCodeView || MMI->getModule()->getDwarfVersion()) {
315+
if (!EmitCodeView || M.getDwarfVersion()) {
317316
DD = new DwarfDebug(this, &M);
318317
DD->beginModule();
319318
Handlers.emplace_back(std::unique_ptr<DwarfDebug>(DD), DbgTimerName,
@@ -376,8 +375,7 @@ bool AsmPrinter::doInitialization(Module &M) {
376375
DWARFGroupDescription);
377376

378377
// Emit tables for any value of cfguard flag (i.e. cfguard=1 or cfguard=2).
379-
if (mdconst::extract_or_null<ConstantInt>(
380-
MMI->getModule()->getModuleFlag("cfguard")))
378+
if (mdconst::extract_or_null<ConstantInt>(M.getModuleFlag("cfguard")))
381379
Handlers.emplace_back(std::make_unique<WinCFGuard>(this), CFGuardName,
382380
CFGuardDescription, DWARFGroupName,
383381
DWARFGroupDescription);
@@ -1051,9 +1049,9 @@ void AsmPrinter::emitStackSizeSection(const MachineFunction &MF) {
10511049
OutStreamer->PopSection();
10521050
}
10531051

1054-
static bool needFuncLabelsForEHOrDebugInfo(const MachineFunction &MF,
1055-
MachineModuleInfo *MMI) {
1056-
if (!MF.getLandingPads().empty() || MF.hasEHFunclets() || MMI->hasDebugInfo())
1052+
static bool needFuncLabelsForEHOrDebugInfo(const MachineFunction &MF) {
1053+
MachineModuleInfo &MMI = MF.getMMI();
1054+
if (!MF.getLandingPads().empty() || MF.hasEHFunclets() || MMI.hasDebugInfo())
10571055
return true;
10581056

10591057
// We might emit an EH table that uses function begin and end labels even if
@@ -1261,7 +1259,7 @@ void AsmPrinter::emitFunctionBody() {
12611259
// Emit target-specific gunk after the function body.
12621260
emitFunctionBodyEnd();
12631261

1264-
if (needFuncLabelsForEHOrDebugInfo(*MF, MMI) ||
1262+
if (needFuncLabelsForEHOrDebugInfo(*MF) ||
12651263
MAI->hasDotTypeDotSizeDirective()) {
12661264
// Create a symbol for the end of function.
12671265
CurrentFnEnd = createTempSymbol("func_end");
@@ -1789,7 +1787,7 @@ void AsmPrinter::SetupMachineFunction(MachineFunction &MF) {
17891787
if (F.hasFnAttribute("patchable-function-entry") ||
17901788
F.hasFnAttribute("function-instrument") ||
17911789
F.hasFnAttribute("xray-instruction-threshold") ||
1792-
needFuncLabelsForEHOrDebugInfo(MF, MMI) || NeedsLocalForSize ||
1790+
needFuncLabelsForEHOrDebugInfo(MF) || NeedsLocalForSize ||
17931791
MF.getTarget().Options.EmitStackSizeSection) {
17941792
CurrentFnBegin = createTempSymbol("func_begin");
17951793
if (NeedsLocalForSize)

llvm/lib/CodeGen/BBSectionsPrepare.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ bool BBSectionsPrepare::doInitialization(Module &M) {
448448

449449
void BBSectionsPrepare::getAnalysisUsage(AnalysisUsage &AU) const {
450450
AU.setPreservesAll();
451-
AU.addRequired<MachineModuleInfoWrapperPass>();
451+
MachineFunctionPass::getAnalysisUsage(AU);
452452
}
453453

454454
MachineFunctionPass *

llvm/lib/CodeGen/BranchFolding.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,8 @@ bool BranchFolderPass::runOnMachineFunction(MachineFunction &MF) {
135135
BranchFolder Folder(EnableTailMerge, /*CommonHoist=*/true, MBBFreqInfo,
136136
getAnalysis<MachineBranchProbabilityInfo>(),
137137
&getAnalysis<ProfileSummaryInfoWrapperPass>().getPSI());
138-
auto *MMIWP = getAnalysisIfAvailable<MachineModuleInfoWrapperPass>();
139-
return Folder.OptimizeFunction(
140-
MF, MF.getSubtarget().getInstrInfo(), MF.getSubtarget().getRegisterInfo(),
141-
MMIWP ? &MMIWP->getMMI() : nullptr);
138+
return Folder.OptimizeFunction(MF, MF.getSubtarget().getInstrInfo(),
139+
MF.getSubtarget().getRegisterInfo());
142140
}
143141

144142
BranchFolder::BranchFolder(bool defaultEnableTailMerge, bool CommonHoist,
@@ -184,7 +182,6 @@ void BranchFolder::RemoveDeadBlock(MachineBasicBlock *MBB) {
184182
bool BranchFolder::OptimizeFunction(MachineFunction &MF,
185183
const TargetInstrInfo *tii,
186184
const TargetRegisterInfo *tri,
187-
MachineModuleInfo *mmi,
188185
MachineLoopInfo *mli, bool AfterPlacement) {
189186
if (!tii) return false;
190187

@@ -194,7 +191,6 @@ bool BranchFolder::OptimizeFunction(MachineFunction &MF,
194191
AfterBlockPlacement = AfterPlacement;
195192
TII = tii;
196193
TRI = tri;
197-
MMI = mmi;
198194
MLI = mli;
199195
this->MRI = &MRI;
200196

llvm/lib/CodeGen/BranchFolding.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class TargetRegisterInfo;
4545
/// given function. Block placement changes the layout and may create new
4646
/// tail merging opportunities.
4747
bool OptimizeFunction(MachineFunction &MF, const TargetInstrInfo *tii,
48-
const TargetRegisterInfo *tri, MachineModuleInfo *mmi,
48+
const TargetRegisterInfo *tri,
4949
MachineLoopInfo *mli = nullptr,
5050
bool AfterPlacement = false);
5151

@@ -124,7 +124,6 @@ class TargetRegisterInfo;
124124
const TargetInstrInfo *TII;
125125
const MachineRegisterInfo *MRI;
126126
const TargetRegisterInfo *TRI;
127-
MachineModuleInfo *MMI;
128127
MachineLoopInfo *MLI;
129128
LivePhysRegs LiveRegs;
130129

llvm/lib/CodeGen/GCRootLowering.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ class LowerIntrinsics : public FunctionPass {
5757
/// GCMetadata record for each function.
5858
class GCMachineCodeAnalysis : public MachineFunctionPass {
5959
GCFunctionInfo *FI;
60-
MachineModuleInfo *MMI;
6160
const TargetInstrInfo *TII;
6261

6362
void FindSafePoints(MachineFunction &MF);
@@ -249,7 +248,6 @@ GCMachineCodeAnalysis::GCMachineCodeAnalysis() : MachineFunctionPass(ID) {}
249248
void GCMachineCodeAnalysis::getAnalysisUsage(AnalysisUsage &AU) const {
250249
MachineFunctionPass::getAnalysisUsage(AU);
251250
AU.setPreservesAll();
252-
AU.addRequired<MachineModuleInfoWrapperPass>();
253251
AU.addRequired<GCModuleInfo>();
254252
}
255253

@@ -310,7 +308,6 @@ bool GCMachineCodeAnalysis::runOnMachineFunction(MachineFunction &MF) {
310308
return false;
311309

312310
FI = &getAnalysis<GCModuleInfo>().getFunctionInfo(MF.getFunction());
313-
MMI = &getAnalysis<MachineModuleInfoWrapperPass>().getMMI();
314311
TII = MF.getSubtarget().getInstrInfo();
315312

316313
// Find the size of the stack frame. There may be no correct static frame

llvm/lib/CodeGen/IfConversion.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -463,10 +463,7 @@ bool IfConverter::runOnMachineFunction(MachineFunction &MF) {
463463
if (!PreRegAlloc) {
464464
// Tail merge tend to expose more if-conversion opportunities.
465465
BranchFolder BF(true, false, MBFI, *MBPI, PSI);
466-
auto *MMIWP = getAnalysisIfAvailable<MachineModuleInfoWrapperPass>();
467-
BFChange = BF.OptimizeFunction(
468-
MF, TII, ST.getRegisterInfo(),
469-
MMIWP ? &MMIWP->getMMI() : nullptr);
466+
BFChange = BF.OptimizeFunction(MF, TII, ST.getRegisterInfo());
470467
}
471468

472469
LLVM_DEBUG(dbgs() << "\nIfcvt: function (" << ++FnNum << ") \'"
@@ -605,10 +602,7 @@ bool IfConverter::runOnMachineFunction(MachineFunction &MF) {
605602

606603
if (MadeChange && IfCvtBranchFold) {
607604
BranchFolder BF(false, false, MBFI, *MBPI, PSI);
608-
auto *MMIWP = getAnalysisIfAvailable<MachineModuleInfoWrapperPass>();
609-
BF.OptimizeFunction(
610-
MF, TII, MF.getSubtarget().getRegisterInfo(),
611-
MMIWP ? &MMIWP->getMMI() : nullptr);
605+
BF.OptimizeFunction(MF, TII, MF.getSubtarget().getRegisterInfo());
612606
}
613607

614608
MadeChange |= BFChange;

llvm/lib/CodeGen/MachineBlockPlacement.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3329,9 +3329,7 @@ bool MachineBlockPlacement::runOnMachineFunction(MachineFunction &MF) {
33293329
BranchFolder BF(/*EnableTailMerge=*/true, /*CommonHoist=*/false, *MBFI,
33303330
*MBPI, PSI, TailMergeSize);
33313331

3332-
auto *MMIWP = getAnalysisIfAvailable<MachineModuleInfoWrapperPass>();
3333-
if (BF.OptimizeFunction(MF, TII, MF.getSubtarget().getRegisterInfo(),
3334-
MMIWP ? &MMIWP->getMMI() : nullptr, MLI,
3332+
if (BF.OptimizeFunction(MF, TII, MF.getSubtarget().getRegisterInfo(), MLI,
33353333
/*AfterPlacement=*/true)) {
33363334
// Redo the layout if tail merging creates/removes/moves blocks.
33373335
BlockToChain.clear();

llvm/lib/CodeGen/UnreachableBlockElim.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ namespace {
8181
class UnreachableMachineBlockElim : public MachineFunctionPass {
8282
bool runOnMachineFunction(MachineFunction &F) override;
8383
void getAnalysisUsage(AnalysisUsage &AU) const override;
84-
MachineModuleInfo *MMI;
84+
8585
public:
8686
static char ID; // Pass identification, replacement for typeid
8787
UnreachableMachineBlockElim() : MachineFunctionPass(ID) {}
@@ -104,8 +104,6 @@ bool UnreachableMachineBlockElim::runOnMachineFunction(MachineFunction &F) {
104104
df_iterator_default_set<MachineBasicBlock*> Reachable;
105105
bool ModifiedPHI = false;
106106

107-
auto *MMIWP = getAnalysisIfAvailable<MachineModuleInfoWrapperPass>();
108-
MMI = MMIWP ? &MMIWP->getMMI() : nullptr;
109107
MachineDominatorTree *MDT = getAnalysisIfAvailable<MachineDominatorTree>();
110108
MachineLoopInfo *MLI = getAnalysisIfAvailable<MachineLoopInfo>();
111109

llvm/lib/Target/AArch64/AArch64SLSHardening.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -403,12 +403,6 @@ class AArch64IndirectThunks : public MachineFunctionPass {
403403
bool doInitialization(Module &M) override;
404404
bool runOnMachineFunction(MachineFunction &MF) override;
405405

406-
void getAnalysisUsage(AnalysisUsage &AU) const override {
407-
MachineFunctionPass::getAnalysisUsage(AU);
408-
AU.addRequired<MachineModuleInfoWrapperPass>();
409-
AU.addPreserved<MachineModuleInfoWrapperPass>();
410-
}
411-
412406
private:
413407
std::tuple<SLSBLRThunkInserter> TIs;
414408

llvm/lib/Target/X86/X86IndirectThunks.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,6 @@ class X86IndirectThunks : public MachineFunctionPass {
110110
bool doInitialization(Module &M) override;
111111
bool runOnMachineFunction(MachineFunction &MF) override;
112112

113-
void getAnalysisUsage(AnalysisUsage &AU) const override {
114-
MachineFunctionPass::getAnalysisUsage(AU);
115-
AU.addRequired<MachineModuleInfoWrapperPass>();
116-
AU.addPreserved<MachineModuleInfoWrapperPass>();
117-
}
118-
119113
private:
120114
std::tuple<RetpolineThunkInserter, LVIThunkInserter> TIs;
121115

llvm/lib/Target/X86/X86InsertPrefetch.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ bool X86InsertPrefetch::doInitialization(Module &M) {
173173

174174
void X86InsertPrefetch::getAnalysisUsage(AnalysisUsage &AU) const {
175175
AU.setPreservesAll();
176-
AU.addRequired<MachineModuleInfoWrapperPass>();
176+
MachineFunctionPass::getAnalysisUsage(AU);
177177
}
178178

179179
bool X86InsertPrefetch::runOnMachineFunction(MachineFunction &MF) {

0 commit comments

Comments
 (0)