aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineModuleInfo.cpp
diff options
context:
space:
mode:
authorYuanfang Chen <yuanfang.chen@sony.com>2019-09-30 17:54:50 +0000
committerYuanfang Chen <yuanfang.chen@sony.com>2019-09-30 17:54:50 +0000
commitcc382cf72736294a409a4d79db11f0cbc3cc5ae1 (patch)
tree5df52deed41d3beb88986a18cc5d2e2f29820977 /llvm/lib/CodeGen/MachineModuleInfo.cpp
parent72131161a41908298270ec45834fd032cb0fa947 (diff)
downloadllvm-cc382cf72736294a409a4d79db11f0cbc3cc5ae1.zip
llvm-cc382cf72736294a409a4d79db11f0cbc3cc5ae1.tar.gz
llvm-cc382cf72736294a409a4d79db11f0cbc3cc5ae1.tar.bz2
[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
Diffstat (limited to 'llvm/lib/CodeGen/MachineModuleInfo.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineModuleInfo.cpp83
1 files changed, 60 insertions, 23 deletions
diff --git a/llvm/lib/CodeGen/MachineModuleInfo.cpp b/llvm/lib/CodeGen/MachineModuleInfo.cpp
index 3dca5a6..50a9251 100644
--- a/llvm/lib/CodeGen/MachineModuleInfo.cpp
+++ b/llvm/lib/CodeGen/MachineModuleInfo.cpp
@@ -36,11 +36,6 @@
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)
-char MachineModuleInfo::ID = 0;
-
// Out of line virtual method.
MachineModuleInfoImpl::~MachineModuleInfoImpl() = default;
@@ -193,27 +188,15 @@ void MMIAddrLabelMapCallbackPtr::allUsesReplacedWith(Value *V2) {
Map->UpdateForRAUWBlock(cast<BasicBlock>(getValPtr()), cast<BasicBlock>(V2));
}
-MachineModuleInfo::MachineModuleInfo(const LLVMTargetMachine *TM)
- : ImmutablePass(ID), TM(*TM),
- Context(TM->getMCAsmInfo(), TM->getMCRegisterInfo(),
- TM->getObjFileLowering(), nullptr, nullptr, false) {
- initializeMachineModuleInfoPass(*PassRegistry::getPassRegistry());
-}
-
-MachineModuleInfo::~MachineModuleInfo() = default;
-
-bool MachineModuleInfo::doInitialization(Module &M) {
+void MachineModuleInfo::initialize() {
ObjFileMMI = nullptr;
CurCallSite = 0;
UsesMSVCFloatingPoint = UsesMorestackAddr = false;
HasSplitStack = HasNosplitStack = false;
AddrLabelSymbols = nullptr;
- TheModule = &M;
- DbgInfoAvailable = !llvm::empty(M.debug_compile_units());
- return false;
}
-bool MachineModuleInfo::doFinalization(Module &M) {
+void MachineModuleInfo::finalize() {
Personalities.clear();
delete AddrLabelSymbols;
@@ -223,10 +206,30 @@ bool MachineModuleInfo::doFinalization(Module &M) {
delete ObjFileMMI;
ObjFileMMI = nullptr;
+}
- return false;
+MachineModuleInfo::MachineModuleInfo(MachineModuleInfo &&MMI)
+ : TM(std::move(MMI.TM)),
+ Context(MMI.TM.getMCAsmInfo(), MMI.TM.getMCRegisterInfo(),
+ MMI.TM.getObjFileLowering(), nullptr, nullptr, false) {
+ ObjFileMMI = MMI.ObjFileMMI;
+ CurCallSite = MMI.CurCallSite;
+ UsesMSVCFloatingPoint = MMI.UsesMSVCFloatingPoint;
+ UsesMorestackAddr = MMI.UsesMorestackAddr;
+ HasSplitStack = MMI.HasSplitStack;
+ HasNosplitStack = MMI.HasNosplitStack;
+ AddrLabelSymbols = MMI.AddrLabelSymbols;
+ TheModule = MMI.TheModule;
}
+MachineModuleInfo::MachineModuleInfo(const LLVMTargetMachine *TM)
+ : TM(*TM), Context(TM->getMCAsmInfo(), TM->getMCRegisterInfo(),
+ TM->getObjFileLowering(), nullptr, nullptr, false) {
+ initialize();
+}
+
+MachineModuleInfo::~MachineModuleInfo() { finalize(); }
+
//===- Address of Block Management ----------------------------------------===//
ArrayRef<MCSymbol *>
@@ -305,12 +308,13 @@ public:
FreeMachineFunction() : FunctionPass(ID) {}
void getAnalysisUsage(AnalysisUsage &AU) const override {
- AU.addRequired<MachineModuleInfo>();
- AU.addPreserved<MachineModuleInfo>();
+ AU.addRequired<MachineModuleInfoWrapperPass>();
+ AU.addPreserved<MachineModuleInfoWrapperPass>();
}
bool runOnFunction(Function &F) override {
- MachineModuleInfo &MMI = getAnalysis<MachineModuleInfo>();
+ MachineModuleInfo &MMI =
+ getAnalysis<MachineModuleInfoWrapperPass>().getMMI();
MMI.deleteMachineFunctionFor(F);
return true;
}
@@ -327,3 +331,36 @@ char FreeMachineFunction::ID;
FunctionPass *llvm::createFreeMachineFunctionPass() {
return new FreeMachineFunction();
}
+
+MachineModuleInfoWrapperPass::MachineModuleInfoWrapperPass(
+ const LLVMTargetMachine *TM)
+ : ImmutablePass(ID), MMI(TM) {
+ initializeMachineModuleInfoWrapperPassPass(*PassRegistry::getPassRegistry());
+}
+
+// Handle the Pass registration stuff necessary to use DataLayout's.
+INITIALIZE_PASS(MachineModuleInfoWrapperPass, "machinemoduleinfo",
+ "Machine Module Information", false, false)
+char MachineModuleInfoWrapperPass::ID = 0;
+
+bool MachineModuleInfoWrapperPass::doInitialization(Module &M) {
+ MMI.initialize();
+ MMI.TheModule = &M;
+ MMI.DbgInfoAvailable = !empty(M.debug_compile_units());
+ return false;
+}
+
+bool MachineModuleInfoWrapperPass::doFinalization(Module &M) {
+ MMI.finalize();
+ return false;
+}
+
+AnalysisKey MachineModuleAnalysis::Key;
+
+MachineModuleInfo MachineModuleAnalysis::run(Module &M,
+ ModuleAnalysisManager &) {
+ MachineModuleInfo MMI(TM);
+ MMI.TheModule = &M;
+ MMI.DbgInfoAvailable = !empty(M.debug_compile_units());
+ return MMI;
+}