forked from OSchip/llvm-project
[NFC] Clean up uses of MachineModuleInfoWrapperPass
This commit is contained in:
parent
0f6afd946d
commit
78c69a00a4
|
@ -244,7 +244,6 @@ const MCSection *AsmPrinter::getCurrentSection() const {
|
||||||
void AsmPrinter::getAnalysisUsage(AnalysisUsage &AU) const {
|
void AsmPrinter::getAnalysisUsage(AnalysisUsage &AU) const {
|
||||||
AU.setPreservesAll();
|
AU.setPreservesAll();
|
||||||
MachineFunctionPass::getAnalysisUsage(AU);
|
MachineFunctionPass::getAnalysisUsage(AU);
|
||||||
AU.addRequired<MachineModuleInfoWrapperPass>();
|
|
||||||
AU.addRequired<MachineOptimizationRemarkEmitterPass>();
|
AU.addRequired<MachineOptimizationRemarkEmitterPass>();
|
||||||
AU.addRequired<GCModuleInfo>();
|
AU.addRequired<GCModuleInfo>();
|
||||||
}
|
}
|
||||||
|
@ -306,14 +305,14 @@ bool AsmPrinter::doInitialization(Module &M) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MAI->doesSupportDebugInformation()) {
|
if (MAI->doesSupportDebugInformation()) {
|
||||||
bool EmitCodeView = MMI->getModule()->getCodeViewFlag();
|
bool EmitCodeView = M.getCodeViewFlag();
|
||||||
if (EmitCodeView && TM.getTargetTriple().isOSWindows()) {
|
if (EmitCodeView && TM.getTargetTriple().isOSWindows()) {
|
||||||
Handlers.emplace_back(std::make_unique<CodeViewDebug>(this),
|
Handlers.emplace_back(std::make_unique<CodeViewDebug>(this),
|
||||||
DbgTimerName, DbgTimerDescription,
|
DbgTimerName, DbgTimerDescription,
|
||||||
CodeViewLineTablesGroupName,
|
CodeViewLineTablesGroupName,
|
||||||
CodeViewLineTablesGroupDescription);
|
CodeViewLineTablesGroupDescription);
|
||||||
}
|
}
|
||||||
if (!EmitCodeView || MMI->getModule()->getDwarfVersion()) {
|
if (!EmitCodeView || M.getDwarfVersion()) {
|
||||||
DD = new DwarfDebug(this, &M);
|
DD = new DwarfDebug(this, &M);
|
||||||
DD->beginModule();
|
DD->beginModule();
|
||||||
Handlers.emplace_back(std::unique_ptr<DwarfDebug>(DD), DbgTimerName,
|
Handlers.emplace_back(std::unique_ptr<DwarfDebug>(DD), DbgTimerName,
|
||||||
|
@ -376,8 +375,7 @@ bool AsmPrinter::doInitialization(Module &M) {
|
||||||
DWARFGroupDescription);
|
DWARFGroupDescription);
|
||||||
|
|
||||||
// Emit tables for any value of cfguard flag (i.e. cfguard=1 or cfguard=2).
|
// Emit tables for any value of cfguard flag (i.e. cfguard=1 or cfguard=2).
|
||||||
if (mdconst::extract_or_null<ConstantInt>(
|
if (mdconst::extract_or_null<ConstantInt>(M.getModuleFlag("cfguard")))
|
||||||
MMI->getModule()->getModuleFlag("cfguard")))
|
|
||||||
Handlers.emplace_back(std::make_unique<WinCFGuard>(this), CFGuardName,
|
Handlers.emplace_back(std::make_unique<WinCFGuard>(this), CFGuardName,
|
||||||
CFGuardDescription, DWARFGroupName,
|
CFGuardDescription, DWARFGroupName,
|
||||||
DWARFGroupDescription);
|
DWARFGroupDescription);
|
||||||
|
@ -1051,9 +1049,9 @@ void AsmPrinter::emitStackSizeSection(const MachineFunction &MF) {
|
||||||
OutStreamer->PopSection();
|
OutStreamer->PopSection();
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool needFuncLabelsForEHOrDebugInfo(const MachineFunction &MF,
|
static bool needFuncLabelsForEHOrDebugInfo(const MachineFunction &MF) {
|
||||||
MachineModuleInfo *MMI) {
|
MachineModuleInfo &MMI = MF.getMMI();
|
||||||
if (!MF.getLandingPads().empty() || MF.hasEHFunclets() || MMI->hasDebugInfo())
|
if (!MF.getLandingPads().empty() || MF.hasEHFunclets() || MMI.hasDebugInfo())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// We might emit an EH table that uses function begin and end labels even if
|
// 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.
|
// Emit target-specific gunk after the function body.
|
||||||
emitFunctionBodyEnd();
|
emitFunctionBodyEnd();
|
||||||
|
|
||||||
if (needFuncLabelsForEHOrDebugInfo(*MF, MMI) ||
|
if (needFuncLabelsForEHOrDebugInfo(*MF) ||
|
||||||
MAI->hasDotTypeDotSizeDirective()) {
|
MAI->hasDotTypeDotSizeDirective()) {
|
||||||
// Create a symbol for the end of function.
|
// Create a symbol for the end of function.
|
||||||
CurrentFnEnd = createTempSymbol("func_end");
|
CurrentFnEnd = createTempSymbol("func_end");
|
||||||
|
@ -1789,7 +1787,7 @@ void AsmPrinter::SetupMachineFunction(MachineFunction &MF) {
|
||||||
if (F.hasFnAttribute("patchable-function-entry") ||
|
if (F.hasFnAttribute("patchable-function-entry") ||
|
||||||
F.hasFnAttribute("function-instrument") ||
|
F.hasFnAttribute("function-instrument") ||
|
||||||
F.hasFnAttribute("xray-instruction-threshold") ||
|
F.hasFnAttribute("xray-instruction-threshold") ||
|
||||||
needFuncLabelsForEHOrDebugInfo(MF, MMI) || NeedsLocalForSize ||
|
needFuncLabelsForEHOrDebugInfo(MF) || NeedsLocalForSize ||
|
||||||
MF.getTarget().Options.EmitStackSizeSection) {
|
MF.getTarget().Options.EmitStackSizeSection) {
|
||||||
CurrentFnBegin = createTempSymbol("func_begin");
|
CurrentFnBegin = createTempSymbol("func_begin");
|
||||||
if (NeedsLocalForSize)
|
if (NeedsLocalForSize)
|
||||||
|
|
|
@ -448,7 +448,7 @@ bool BBSectionsPrepare::doInitialization(Module &M) {
|
||||||
|
|
||||||
void BBSectionsPrepare::getAnalysisUsage(AnalysisUsage &AU) const {
|
void BBSectionsPrepare::getAnalysisUsage(AnalysisUsage &AU) const {
|
||||||
AU.setPreservesAll();
|
AU.setPreservesAll();
|
||||||
AU.addRequired<MachineModuleInfoWrapperPass>();
|
MachineFunctionPass::getAnalysisUsage(AU);
|
||||||
}
|
}
|
||||||
|
|
||||||
MachineFunctionPass *
|
MachineFunctionPass *
|
||||||
|
|
|
@ -135,10 +135,8 @@ bool BranchFolderPass::runOnMachineFunction(MachineFunction &MF) {
|
||||||
BranchFolder Folder(EnableTailMerge, /*CommonHoist=*/true, MBBFreqInfo,
|
BranchFolder Folder(EnableTailMerge, /*CommonHoist=*/true, MBBFreqInfo,
|
||||||
getAnalysis<MachineBranchProbabilityInfo>(),
|
getAnalysis<MachineBranchProbabilityInfo>(),
|
||||||
&getAnalysis<ProfileSummaryInfoWrapperPass>().getPSI());
|
&getAnalysis<ProfileSummaryInfoWrapperPass>().getPSI());
|
||||||
auto *MMIWP = getAnalysisIfAvailable<MachineModuleInfoWrapperPass>();
|
return Folder.OptimizeFunction(MF, MF.getSubtarget().getInstrInfo(),
|
||||||
return Folder.OptimizeFunction(
|
MF.getSubtarget().getRegisterInfo());
|
||||||
MF, MF.getSubtarget().getInstrInfo(), MF.getSubtarget().getRegisterInfo(),
|
|
||||||
MMIWP ? &MMIWP->getMMI() : nullptr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BranchFolder::BranchFolder(bool defaultEnableTailMerge, bool CommonHoist,
|
BranchFolder::BranchFolder(bool defaultEnableTailMerge, bool CommonHoist,
|
||||||
|
@ -184,7 +182,6 @@ void BranchFolder::RemoveDeadBlock(MachineBasicBlock *MBB) {
|
||||||
bool BranchFolder::OptimizeFunction(MachineFunction &MF,
|
bool BranchFolder::OptimizeFunction(MachineFunction &MF,
|
||||||
const TargetInstrInfo *tii,
|
const TargetInstrInfo *tii,
|
||||||
const TargetRegisterInfo *tri,
|
const TargetRegisterInfo *tri,
|
||||||
MachineModuleInfo *mmi,
|
|
||||||
MachineLoopInfo *mli, bool AfterPlacement) {
|
MachineLoopInfo *mli, bool AfterPlacement) {
|
||||||
if (!tii) return false;
|
if (!tii) return false;
|
||||||
|
|
||||||
|
@ -194,7 +191,6 @@ bool BranchFolder::OptimizeFunction(MachineFunction &MF,
|
||||||
AfterBlockPlacement = AfterPlacement;
|
AfterBlockPlacement = AfterPlacement;
|
||||||
TII = tii;
|
TII = tii;
|
||||||
TRI = tri;
|
TRI = tri;
|
||||||
MMI = mmi;
|
|
||||||
MLI = mli;
|
MLI = mli;
|
||||||
this->MRI = &MRI;
|
this->MRI = &MRI;
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ class TargetRegisterInfo;
|
||||||
/// given function. Block placement changes the layout and may create new
|
/// given function. Block placement changes the layout and may create new
|
||||||
/// tail merging opportunities.
|
/// tail merging opportunities.
|
||||||
bool OptimizeFunction(MachineFunction &MF, const TargetInstrInfo *tii,
|
bool OptimizeFunction(MachineFunction &MF, const TargetInstrInfo *tii,
|
||||||
const TargetRegisterInfo *tri, MachineModuleInfo *mmi,
|
const TargetRegisterInfo *tri,
|
||||||
MachineLoopInfo *mli = nullptr,
|
MachineLoopInfo *mli = nullptr,
|
||||||
bool AfterPlacement = false);
|
bool AfterPlacement = false);
|
||||||
|
|
||||||
|
@ -124,7 +124,6 @@ class TargetRegisterInfo;
|
||||||
const TargetInstrInfo *TII;
|
const TargetInstrInfo *TII;
|
||||||
const MachineRegisterInfo *MRI;
|
const MachineRegisterInfo *MRI;
|
||||||
const TargetRegisterInfo *TRI;
|
const TargetRegisterInfo *TRI;
|
||||||
MachineModuleInfo *MMI;
|
|
||||||
MachineLoopInfo *MLI;
|
MachineLoopInfo *MLI;
|
||||||
LivePhysRegs LiveRegs;
|
LivePhysRegs LiveRegs;
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,6 @@ public:
|
||||||
/// GCMetadata record for each function.
|
/// GCMetadata record for each function.
|
||||||
class GCMachineCodeAnalysis : public MachineFunctionPass {
|
class GCMachineCodeAnalysis : public MachineFunctionPass {
|
||||||
GCFunctionInfo *FI;
|
GCFunctionInfo *FI;
|
||||||
MachineModuleInfo *MMI;
|
|
||||||
const TargetInstrInfo *TII;
|
const TargetInstrInfo *TII;
|
||||||
|
|
||||||
void FindSafePoints(MachineFunction &MF);
|
void FindSafePoints(MachineFunction &MF);
|
||||||
|
@ -249,7 +248,6 @@ GCMachineCodeAnalysis::GCMachineCodeAnalysis() : MachineFunctionPass(ID) {}
|
||||||
void GCMachineCodeAnalysis::getAnalysisUsage(AnalysisUsage &AU) const {
|
void GCMachineCodeAnalysis::getAnalysisUsage(AnalysisUsage &AU) const {
|
||||||
MachineFunctionPass::getAnalysisUsage(AU);
|
MachineFunctionPass::getAnalysisUsage(AU);
|
||||||
AU.setPreservesAll();
|
AU.setPreservesAll();
|
||||||
AU.addRequired<MachineModuleInfoWrapperPass>();
|
|
||||||
AU.addRequired<GCModuleInfo>();
|
AU.addRequired<GCModuleInfo>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -310,7 +308,6 @@ bool GCMachineCodeAnalysis::runOnMachineFunction(MachineFunction &MF) {
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
FI = &getAnalysis<GCModuleInfo>().getFunctionInfo(MF.getFunction());
|
FI = &getAnalysis<GCModuleInfo>().getFunctionInfo(MF.getFunction());
|
||||||
MMI = &getAnalysis<MachineModuleInfoWrapperPass>().getMMI();
|
|
||||||
TII = MF.getSubtarget().getInstrInfo();
|
TII = MF.getSubtarget().getInstrInfo();
|
||||||
|
|
||||||
// Find the size of the stack frame. There may be no correct static frame
|
// Find the size of the stack frame. There may be no correct static frame
|
||||||
|
|
|
@ -463,10 +463,7 @@ bool IfConverter::runOnMachineFunction(MachineFunction &MF) {
|
||||||
if (!PreRegAlloc) {
|
if (!PreRegAlloc) {
|
||||||
// Tail merge tend to expose more if-conversion opportunities.
|
// Tail merge tend to expose more if-conversion opportunities.
|
||||||
BranchFolder BF(true, false, MBFI, *MBPI, PSI);
|
BranchFolder BF(true, false, MBFI, *MBPI, PSI);
|
||||||
auto *MMIWP = getAnalysisIfAvailable<MachineModuleInfoWrapperPass>();
|
BFChange = BF.OptimizeFunction(MF, TII, ST.getRegisterInfo());
|
||||||
BFChange = BF.OptimizeFunction(
|
|
||||||
MF, TII, ST.getRegisterInfo(),
|
|
||||||
MMIWP ? &MMIWP->getMMI() : nullptr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LLVM_DEBUG(dbgs() << "\nIfcvt: function (" << ++FnNum << ") \'"
|
LLVM_DEBUG(dbgs() << "\nIfcvt: function (" << ++FnNum << ") \'"
|
||||||
|
@ -605,10 +602,7 @@ bool IfConverter::runOnMachineFunction(MachineFunction &MF) {
|
||||||
|
|
||||||
if (MadeChange && IfCvtBranchFold) {
|
if (MadeChange && IfCvtBranchFold) {
|
||||||
BranchFolder BF(false, false, MBFI, *MBPI, PSI);
|
BranchFolder BF(false, false, MBFI, *MBPI, PSI);
|
||||||
auto *MMIWP = getAnalysisIfAvailable<MachineModuleInfoWrapperPass>();
|
BF.OptimizeFunction(MF, TII, MF.getSubtarget().getRegisterInfo());
|
||||||
BF.OptimizeFunction(
|
|
||||||
MF, TII, MF.getSubtarget().getRegisterInfo(),
|
|
||||||
MMIWP ? &MMIWP->getMMI() : nullptr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MadeChange |= BFChange;
|
MadeChange |= BFChange;
|
||||||
|
|
|
@ -3329,9 +3329,7 @@ bool MachineBlockPlacement::runOnMachineFunction(MachineFunction &MF) {
|
||||||
BranchFolder BF(/*EnableTailMerge=*/true, /*CommonHoist=*/false, *MBFI,
|
BranchFolder BF(/*EnableTailMerge=*/true, /*CommonHoist=*/false, *MBFI,
|
||||||
*MBPI, PSI, TailMergeSize);
|
*MBPI, PSI, TailMergeSize);
|
||||||
|
|
||||||
auto *MMIWP = getAnalysisIfAvailable<MachineModuleInfoWrapperPass>();
|
if (BF.OptimizeFunction(MF, TII, MF.getSubtarget().getRegisterInfo(), MLI,
|
||||||
if (BF.OptimizeFunction(MF, TII, MF.getSubtarget().getRegisterInfo(),
|
|
||||||
MMIWP ? &MMIWP->getMMI() : nullptr, MLI,
|
|
||||||
/*AfterPlacement=*/true)) {
|
/*AfterPlacement=*/true)) {
|
||||||
// Redo the layout if tail merging creates/removes/moves blocks.
|
// Redo the layout if tail merging creates/removes/moves blocks.
|
||||||
BlockToChain.clear();
|
BlockToChain.clear();
|
||||||
|
|
|
@ -81,7 +81,7 @@ namespace {
|
||||||
class UnreachableMachineBlockElim : public MachineFunctionPass {
|
class UnreachableMachineBlockElim : public MachineFunctionPass {
|
||||||
bool runOnMachineFunction(MachineFunction &F) override;
|
bool runOnMachineFunction(MachineFunction &F) override;
|
||||||
void getAnalysisUsage(AnalysisUsage &AU) const override;
|
void getAnalysisUsage(AnalysisUsage &AU) const override;
|
||||||
MachineModuleInfo *MMI;
|
|
||||||
public:
|
public:
|
||||||
static char ID; // Pass identification, replacement for typeid
|
static char ID; // Pass identification, replacement for typeid
|
||||||
UnreachableMachineBlockElim() : MachineFunctionPass(ID) {}
|
UnreachableMachineBlockElim() : MachineFunctionPass(ID) {}
|
||||||
|
@ -104,8 +104,6 @@ bool UnreachableMachineBlockElim::runOnMachineFunction(MachineFunction &F) {
|
||||||
df_iterator_default_set<MachineBasicBlock*> Reachable;
|
df_iterator_default_set<MachineBasicBlock*> Reachable;
|
||||||
bool ModifiedPHI = false;
|
bool ModifiedPHI = false;
|
||||||
|
|
||||||
auto *MMIWP = getAnalysisIfAvailable<MachineModuleInfoWrapperPass>();
|
|
||||||
MMI = MMIWP ? &MMIWP->getMMI() : nullptr;
|
|
||||||
MachineDominatorTree *MDT = getAnalysisIfAvailable<MachineDominatorTree>();
|
MachineDominatorTree *MDT = getAnalysisIfAvailable<MachineDominatorTree>();
|
||||||
MachineLoopInfo *MLI = getAnalysisIfAvailable<MachineLoopInfo>();
|
MachineLoopInfo *MLI = getAnalysisIfAvailable<MachineLoopInfo>();
|
||||||
|
|
||||||
|
|
|
@ -403,12 +403,6 @@ public:
|
||||||
bool doInitialization(Module &M) override;
|
bool doInitialization(Module &M) override;
|
||||||
bool runOnMachineFunction(MachineFunction &MF) override;
|
bool runOnMachineFunction(MachineFunction &MF) override;
|
||||||
|
|
||||||
void getAnalysisUsage(AnalysisUsage &AU) const override {
|
|
||||||
MachineFunctionPass::getAnalysisUsage(AU);
|
|
||||||
AU.addRequired<MachineModuleInfoWrapperPass>();
|
|
||||||
AU.addPreserved<MachineModuleInfoWrapperPass>();
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::tuple<SLSBLRThunkInserter> TIs;
|
std::tuple<SLSBLRThunkInserter> TIs;
|
||||||
|
|
||||||
|
|
|
@ -110,12 +110,6 @@ public:
|
||||||
bool doInitialization(Module &M) override;
|
bool doInitialization(Module &M) override;
|
||||||
bool runOnMachineFunction(MachineFunction &MF) override;
|
bool runOnMachineFunction(MachineFunction &MF) override;
|
||||||
|
|
||||||
void getAnalysisUsage(AnalysisUsage &AU) const override {
|
|
||||||
MachineFunctionPass::getAnalysisUsage(AU);
|
|
||||||
AU.addRequired<MachineModuleInfoWrapperPass>();
|
|
||||||
AU.addPreserved<MachineModuleInfoWrapperPass>();
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::tuple<RetpolineThunkInserter, LVIThunkInserter> TIs;
|
std::tuple<RetpolineThunkInserter, LVIThunkInserter> TIs;
|
||||||
|
|
||||||
|
|
|
@ -173,7 +173,7 @@ bool X86InsertPrefetch::doInitialization(Module &M) {
|
||||||
|
|
||||||
void X86InsertPrefetch::getAnalysisUsage(AnalysisUsage &AU) const {
|
void X86InsertPrefetch::getAnalysisUsage(AnalysisUsage &AU) const {
|
||||||
AU.setPreservesAll();
|
AU.setPreservesAll();
|
||||||
AU.addRequired<MachineModuleInfoWrapperPass>();
|
MachineFunctionPass::getAnalysisUsage(AU);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool X86InsertPrefetch::runOnMachineFunction(MachineFunction &MF) {
|
bool X86InsertPrefetch::runOnMachineFunction(MachineFunction &MF) {
|
||||||
|
|
Loading…
Reference in New Issue