diff options
author | Matthias Braun <matze@braunis.de> | 2016-08-24 00:42:05 +0000 |
---|---|---|
committer | Matthias Braun <matze@braunis.de> | 2016-08-24 00:42:05 +0000 |
commit | c3b2e80b9d7615190bb5d50f17d6524c2fd8d66d (patch) | |
tree | 464f32d68c01481e6c6ec8ec9d6954ebd7a4f5be /llvm/lib | |
parent | 7fe0681e28379ed875367b7fdd4032b761c0bc1c (diff) | |
download | bcm5719-llvm-c3b2e80b9d7615190bb5d50f17d6524c2fd8d66d.tar.gz bcm5719-llvm-c3b2e80b9d7615190bb5d50f17d6524c2fd8d66d.zip |
MachineModuleInfo: Avoid dummy constructor, use INITIALIZE_TM_PASS
Change this pass constructor to just accept a const TargetMachine * and
use INITIALIZE_TM_PASS, that way we can get rid of the dummy
constructor. The pass will still fail when calling the default
constructor leading to TM == nullptr, this is no different than before
but is more in line what other codegen passes are doing and avoids the
dummy constructor.
llvm-svn: 279598
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/CodeGen/LLVMTargetMachine.cpp | 14 | ||||
-rw-r--r-- | llvm/lib/CodeGen/MachineModuleInfo.cpp | 20 |
2 files changed, 10 insertions, 24 deletions
diff --git a/llvm/lib/CodeGen/LLVMTargetMachine.cpp b/llvm/lib/CodeGen/LLVMTargetMachine.cpp index 9ed61c6685b..448bfaa77eb 100644 --- a/llvm/lib/CodeGen/LLVMTargetMachine.cpp +++ b/llvm/lib/CodeGen/LLVMTargetMachine.cpp @@ -102,15 +102,6 @@ TargetIRAnalysis LLVMTargetMachine::getTargetIRAnalysis() { }); } -MachineModuleInfo & -LLVMTargetMachine::addMachineModuleInfo(PassManagerBase &PM) const { - MachineModuleInfo *MMI = new MachineModuleInfo(*getMCAsmInfo(), - *getMCRegisterInfo(), - getObjFileLowering()); - PM.add(MMI); - return *MMI; -} - void LLVMTargetMachine::addMachineFunctionAnalysis(PassManagerBase &PM, MachineFunctionInitializer *MFInitializer) const { PM.add(new MachineFunctionAnalysis(*this, MFInitializer)); @@ -150,7 +141,8 @@ addPassesToGenerateCode(LLVMTargetMachine *TM, PassManagerBase &PM, PassConfig->addISelPrepare(); - MachineModuleInfo &MMI = TM->addMachineModuleInfo(PM); + MachineModuleInfo *MMI = new MachineModuleInfo(TM); + PM.add(MMI); TM->addMachineFunctionAnalysis(PM, MFInitializer); // Enable FastISel with -fast, but allow that to be overridden. @@ -189,7 +181,7 @@ addPassesToGenerateCode(LLVMTargetMachine *TM, PassManagerBase &PM, PassConfig->setInitialized(); - return &MMI.getContext(); + return &MMI->getContext(); } bool LLVMTargetMachine::addPassesToEmitFile( diff --git a/llvm/lib/CodeGen/MachineModuleInfo.cpp b/llvm/lib/CodeGen/MachineModuleInfo.cpp index 244e3fbc4e8..c2721e1d77e 100644 --- a/llvm/lib/CodeGen/MachineModuleInfo.cpp +++ b/llvm/lib/CodeGen/MachineModuleInfo.cpp @@ -23,12 +23,14 @@ #include "llvm/MC/MCSymbol.h" #include "llvm/Support/Dwarf.h" #include "llvm/Support/ErrorHandling.h" +#include "llvm/Target/TargetLoweringObjectFile.h" +#include "llvm/Target/TargetMachine.h" using namespace llvm; using namespace llvm::dwarf; // Handle the Pass registration stuff necessary to use DataLayout's. -INITIALIZE_PASS(MachineModuleInfo, "machinemoduleinfo", - "Machine Module Information", false, false) +INITIALIZE_TM_PASS(MachineModuleInfo, "machinemoduleinfo", + "Machine Module Information", false, false) char MachineModuleInfo::ID = 0; // Out of line virtual method. @@ -186,20 +188,12 @@ void MMIAddrLabelMapCallbackPtr::allUsesReplacedWith(Value *V2) { //===----------------------------------------------------------------------===// -MachineModuleInfo::MachineModuleInfo(const MCAsmInfo &MAI, - const MCRegisterInfo &MRI, - const MCObjectFileInfo *MOFI) - : ImmutablePass(ID), Context(&MAI, &MRI, MOFI, nullptr, false) { +MachineModuleInfo::MachineModuleInfo(const TargetMachine *TM) + : ImmutablePass(ID), Context(TM->getMCAsmInfo(), TM->getMCRegisterInfo(), + TM->getObjFileLowering(), nullptr, false) { initializeMachineModuleInfoPass(*PassRegistry::getPassRegistry()); } -MachineModuleInfo::MachineModuleInfo() - : ImmutablePass(ID), Context(nullptr, nullptr, nullptr) { - llvm_unreachable("This MachineModuleInfo constructor should never be called, " - "MMI should always be explicitly constructed by " - "LLVMTargetMachine"); -} - MachineModuleInfo::~MachineModuleInfo() { } |