[NewPM] Port MachineModuleInfo to the new pass manager.
Existing clients are converted to use MachineModuleInfoWrapperPass. The
new interface is for defining a new pass manager API in CodeGen.
Reviewers: fedor.sergeev, philip.pfaffe, chandlerc, arsenm
Reviewed By: arsenm, fedor.sergeev
Differential Revision: https://reviews.llvm.org/D64183
llvm-svn: 373240
diff --git a/llvm/lib/CodeGen/LLVMTargetMachine.cpp b/llvm/lib/CodeGen/LLVMTargetMachine.cpp
index cd70792..1c362ae 100644
--- a/llvm/lib/CodeGen/LLVMTargetMachine.cpp
+++ b/llvm/lib/CodeGen/LLVMTargetMachine.cpp
@@ -96,14 +96,15 @@
/// addPassesToX helper drives creation and initialization of TargetPassConfig.
static TargetPassConfig *
addPassesToGenerateCode(LLVMTargetMachine &TM, PassManagerBase &PM,
- bool DisableVerify, MachineModuleInfo &MMI) {
+ bool DisableVerify,
+ MachineModuleInfoWrapperPass &MMIWP) {
// Targets may override createPassConfig to provide a target-specific
// subclass.
TargetPassConfig *PassConfig = TM.createPassConfig(PM);
// Set PassConfig options provided by TargetMachine.
PassConfig->setDisableVerify(DisableVerify);
PM.add(PassConfig);
- PM.add(&MMI);
+ PM.add(&MMIWP);
if (PassConfig->addISelPasses())
return nullptr;
@@ -186,17 +187,15 @@
return false;
}
-bool LLVMTargetMachine::addPassesToEmitFile(PassManagerBase &PM,
- raw_pwrite_stream &Out,
- raw_pwrite_stream *DwoOut,
- CodeGenFileType FileType,
- bool DisableVerify,
- MachineModuleInfo *MMI) {
+bool LLVMTargetMachine::addPassesToEmitFile(
+ PassManagerBase &PM, raw_pwrite_stream &Out, raw_pwrite_stream *DwoOut,
+ CodeGenFileType FileType, bool DisableVerify,
+ MachineModuleInfoWrapperPass *MMIWP) {
// Add common CodeGen passes.
- if (!MMI)
- MMI = new MachineModuleInfo(this);
+ if (!MMIWP)
+ MMIWP = new MachineModuleInfoWrapperPass(this);
TargetPassConfig *PassConfig =
- addPassesToGenerateCode(*this, PM, DisableVerify, *MMI);
+ addPassesToGenerateCode(*this, PM, DisableVerify, *MMIWP);
if (!PassConfig)
return true;
@@ -206,12 +205,13 @@
// testing to be meaningful, we need to ensure that the symbols created
// are MCSymbolXCOFF variants, which requires that
// the TargetLoweringObjectFile instance has been initialized.
- MCContext &Ctx = MMI->getContext();
+ MCContext &Ctx = MMIWP->getMMI().getContext();
const_cast<TargetLoweringObjectFile &>(*this->getObjFileLowering())
.Initialize(Ctx, *this);
}
PM.add(createPrintMIRPass(Out));
- } else if (addAsmPrinter(PM, Out, DwoOut, FileType, MMI->getContext()))
+ } else if (addAsmPrinter(PM, Out, DwoOut, FileType,
+ MMIWP->getMMI().getContext()))
return true;
PM.add(createFreeMachineFunctionPass());
@@ -227,15 +227,15 @@
raw_pwrite_stream &Out,
bool DisableVerify) {
// Add common CodeGen passes.
- MachineModuleInfo *MMI = new MachineModuleInfo(this);
+ MachineModuleInfoWrapperPass *MMIWP = new MachineModuleInfoWrapperPass(this);
TargetPassConfig *PassConfig =
- addPassesToGenerateCode(*this, PM, DisableVerify, *MMI);
+ addPassesToGenerateCode(*this, PM, DisableVerify, *MMIWP);
if (!PassConfig)
return true;
assert(TargetPassConfig::willCompleteCodeGenPipeline() &&
"Cannot emit MC with limited codegen pipeline");
- Ctx = &MMI->getContext();
+ Ctx = &MMIWP->getMMI().getContext();
if (Options.MCOptions.MCSaveTempLabels)
Ctx->setAllowTemporaryLabels(false);