diff options
Diffstat (limited to 'contrib/llvm-project/llvm/lib/CodeGen/MachineModuleInfo.cpp')
| -rw-r--r-- | contrib/llvm-project/llvm/lib/CodeGen/MachineModuleInfo.cpp | 97 |
1 files changed, 24 insertions, 73 deletions
diff --git a/contrib/llvm-project/llvm/lib/CodeGen/MachineModuleInfo.cpp b/contrib/llvm-project/llvm/lib/CodeGen/MachineModuleInfo.cpp index 0094a923e039..2e720018262c 100644 --- a/contrib/llvm-project/llvm/lib/CodeGen/MachineModuleInfo.cpp +++ b/contrib/llvm-project/llvm/lib/CodeGen/MachineModuleInfo.cpp @@ -20,10 +20,8 @@ #include "llvm/IR/Module.h" #include "llvm/IR/Value.h" #include "llvm/IR/ValueHandle.h" -#include "llvm/InitializePasses.h" #include "llvm/MC/MCContext.h" #include "llvm/MC/MCSymbol.h" -#include "llvm/MC/MCSymbolXCOFF.h" #include "llvm/Pass.h" #include "llvm/Support/Casting.h" #include "llvm/Support/ErrorHandling.h" @@ -38,6 +36,11 @@ 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; @@ -118,17 +121,7 @@ ArrayRef<MCSymbol *> MMIAddrLabelMap::getAddrLabelSymbolToEmit(BasicBlock *BB) { BBCallbacks.back().setMap(this); Entry.Index = BBCallbacks.size() - 1; Entry.Fn = BB->getParent(); - MCSymbol *Sym = Context.createTempSymbol(!BB->hasAddressTaken()); - if (Context.getObjectFileInfo()->getTargetTriple().isOSBinFormatXCOFF()) { - MCSymbol *FnEntryPointSym = - Context.lookupSymbol("." + Entry.Fn->getName()); - assert(FnEntryPointSym && "The function entry pointer symbol should have" - " already been initialized."); - MCSectionXCOFF *Csect = - cast<MCSymbolXCOFF>(FnEntryPointSym)->getContainingCsect(); - cast<MCSymbolXCOFF>(Sym)->setContainingCsect(Csect); - } - Entry.Symbols.push_back(Sym); + Entry.Symbols.push_back(Context.createTempSymbol(!BB->hasAddressTaken())); return Entry.Symbols; } @@ -200,15 +193,27 @@ void MMIAddrLabelMapCallbackPtr::allUsesReplacedWith(Value *V2) { Map->UpdateForRAUWBlock(cast<BasicBlock>(getValPtr()), cast<BasicBlock>(V2)); } -void MachineModuleInfo::initialize() { +MachineModuleInfo::MachineModuleInfo(const LLVMTargetMachine *TM) + : ImmutablePass(ID), TM(*TM), + Context(TM->getMCAsmInfo(), TM->getMCRegisterInfo(), + TM->getObjFileLowering(), nullptr, false) { + initializeMachineModuleInfoPass(*PassRegistry::getPassRegistry()); +} + +MachineModuleInfo::~MachineModuleInfo() = default; + +bool MachineModuleInfo::doInitialization(Module &M) { ObjFileMMI = nullptr; CurCallSite = 0; UsesMSVCFloatingPoint = UsesMorestackAddr = false; HasSplitStack = HasNosplitStack = false; AddrLabelSymbols = nullptr; + TheModule = &M; + DbgInfoAvailable = !llvm::empty(M.debug_compile_units()); + return false; } -void MachineModuleInfo::finalize() { +bool MachineModuleInfo::doFinalization(Module &M) { Personalities.clear(); delete AddrLabelSymbols; @@ -218,30 +223,10 @@ void MachineModuleInfo::finalize() { delete ObjFileMMI; ObjFileMMI = nullptr; -} - -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(); + return false; } -MachineModuleInfo::~MachineModuleInfo() { finalize(); } - //===- Address of Block Management ----------------------------------------===// ArrayRef<MCSymbol *> @@ -320,13 +305,12 @@ public: FreeMachineFunction() : FunctionPass(ID) {} void getAnalysisUsage(AnalysisUsage &AU) const override { - AU.addRequired<MachineModuleInfoWrapperPass>(); - AU.addPreserved<MachineModuleInfoWrapperPass>(); + AU.addRequired<MachineModuleInfo>(); + AU.addPreserved<MachineModuleInfo>(); } bool runOnFunction(Function &F) override { - MachineModuleInfo &MMI = - getAnalysis<MachineModuleInfoWrapperPass>().getMMI(); + MachineModuleInfo &MMI = getAnalysis<MachineModuleInfo>(); MMI.deleteMachineFunctionFor(F); return true; } @@ -343,36 +327,3 @@ 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 = !M.debug_compile_units().empty(); - 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 = !M.debug_compile_units().empty(); - return MMI; -} |
