diff options
Diffstat (limited to 'lib/CodeGen/MachineModuleInfo.cpp')
| -rw-r--r-- | lib/CodeGen/MachineModuleInfo.cpp | 65 | 
1 files changed, 35 insertions, 30 deletions
diff --git a/lib/CodeGen/MachineModuleInfo.cpp b/lib/CodeGen/MachineModuleInfo.cpp index 6cf751d34e26..c1b72430e605 100644 --- a/lib/CodeGen/MachineModuleInfo.cpp +++ b/lib/CodeGen/MachineModuleInfo.cpp @@ -7,27 +7,34 @@  //  //===----------------------------------------------------------------------===// -#include "llvm/CodeGen/MachineModuleInfo.h" -#include "llvm/ADT/PointerUnion.h" +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/DenseMap.h"  #include "llvm/ADT/PostOrderIterator.h" +#include "llvm/ADT/StringRef.h"  #include "llvm/ADT/TinyPtrVector.h" -#include "llvm/Analysis/EHPersonalities.h" -#include "llvm/Analysis/ValueTracking.h"  #include "llvm/CodeGen/MachineFunction.h"  #include "llvm/CodeGen/MachineFunctionInitializer.h" -#include "llvm/CodeGen/MachineFunctionPass.h" +#include "llvm/CodeGen/MachineModuleInfo.h"  #include "llvm/CodeGen/Passes.h" -#include "llvm/IR/Constants.h" +#include "llvm/IR/BasicBlock.h"  #include "llvm/IR/DerivedTypes.h" -#include "llvm/IR/GlobalVariable.h"  #include "llvm/IR/Instructions.h"  #include "llvm/IR/Module.h" -#include "llvm/MC/MCObjectFileInfo.h" +#include "llvm/IR/Value.h" +#include "llvm/IR/ValueHandle.h" +#include "llvm/MC/MCContext.h"  #include "llvm/MC/MCSymbol.h" -#include "llvm/Support/Dwarf.h" +#include "llvm/Pass.h" +#include "llvm/Support/Casting.h"  #include "llvm/Support/ErrorHandling.h"  #include "llvm/Target/TargetLoweringObjectFile.h"  #include "llvm/Target/TargetMachine.h" +#include <algorithm> +#include <cassert> +#include <memory> +#include <utility> +#include <vector> +  using namespace llvm;  using namespace llvm::dwarf; @@ -37,14 +44,16 @@ INITIALIZE_PASS(MachineModuleInfo, "machinemoduleinfo",  char MachineModuleInfo::ID = 0;  // Out of line virtual method. -MachineModuleInfoImpl::~MachineModuleInfoImpl() {} +MachineModuleInfoImpl::~MachineModuleInfoImpl() = default;  namespace llvm { +  class MMIAddrLabelMapCallbackPtr final : CallbackVH { -  MMIAddrLabelMap *Map; +  MMIAddrLabelMap *Map = nullptr; +  public: -  MMIAddrLabelMapCallbackPtr() : Map(nullptr) {} -  MMIAddrLabelMapCallbackPtr(Value *V) : CallbackVH(V), Map(nullptr) {} +  MMIAddrLabelMapCallbackPtr() = default; +  MMIAddrLabelMapCallbackPtr(Value *V) : CallbackVH(V) {}    void setPtr(BasicBlock *BB) {      ValueHandleBase::operator=(BB); @@ -75,11 +84,12 @@ class MMIAddrLabelMap {    /// This is a per-function list of symbols whose corresponding BasicBlock got    /// deleted.  These symbols need to be emitted at some point in the file, so    /// AsmPrinter emits them after the function body. -  DenseMap<AssertingVH<Function>, std::vector<MCSymbol*> > +  DenseMap<AssertingVH<Function>, std::vector<MCSymbol*>>      DeletedAddrLabelsNeedingEmission; -public: +public:    MMIAddrLabelMap(MCContext &context) : Context(context) {} +    ~MMIAddrLabelMap() {      assert(DeletedAddrLabelsNeedingEmission.empty() &&             "Some labels for deleted blocks never got emitted"); @@ -93,7 +103,8 @@ public:    void UpdateForDeletedBlock(BasicBlock *BB);    void UpdateForRAUWBlock(BasicBlock *Old, BasicBlock *New);  }; -} + +} // end namespace llvm  ArrayRef<MCSymbol *> MMIAddrLabelMap::getAddrLabelSymbolToEmit(BasicBlock *BB) {    assert(BB->hasAddressTaken() && @@ -119,7 +130,7 @@ ArrayRef<MCSymbol *> MMIAddrLabelMap::getAddrLabelSymbolToEmit(BasicBlock *BB) {  /// If we have any deleted symbols for F, return them.  void MMIAddrLabelMap::  takeDeletedSymbolsForFunction(Function *F, std::vector<MCSymbol*> &Result) { -  DenseMap<AssertingVH<Function>, std::vector<MCSymbol*> >::iterator I = +  DenseMap<AssertingVH<Function>, std::vector<MCSymbol*>>::iterator I =      DeletedAddrLabelsNeedingEmission.find(F);    // If there are no entries for the function, just return. @@ -130,7 +141,6 @@ takeDeletedSymbolsForFunction(Function *F, std::vector<MCSymbol*> &Result) {    DeletedAddrLabelsNeedingEmission.erase(I);  } -  void MMIAddrLabelMap::UpdateForDeletedBlock(BasicBlock *BB) {    // If the block got deleted, there is no need for the symbol.  If the symbol    // was already emitted, we can just forget about it, otherwise we need to @@ -177,7 +187,6 @@ void MMIAddrLabelMap::UpdateForRAUWBlock(BasicBlock *Old, BasicBlock *New) {                            OldEntry.Symbols.end());  } -  void MMIAddrLabelMapCallbackPtr::deleted() {    Map->UpdateForDeletedBlock(cast<BasicBlock>(getValPtr()));  } @@ -186,9 +195,6 @@ void MMIAddrLabelMapCallbackPtr::allUsesReplacedWith(Value *V2) {    Map->UpdateForRAUWBlock(cast<BasicBlock>(getValPtr()), cast<BasicBlock>(V2));  } - -//===----------------------------------------------------------------------===// -  MachineModuleInfo::MachineModuleInfo(const TargetMachine *TM)    : ImmutablePass(ID), TM(*TM),      Context(TM->getMCAsmInfo(), TM->getMCRegisterInfo(), @@ -196,11 +202,9 @@ MachineModuleInfo::MachineModuleInfo(const TargetMachine *TM)    initializeMachineModuleInfoPass(*PassRegistry::getPassRegistry());  } -MachineModuleInfo::~MachineModuleInfo() { -} +MachineModuleInfo::~MachineModuleInfo() = default;  bool MachineModuleInfo::doInitialization(Module &M) { -    ObjFileMMI = nullptr;    CurCallSite = 0;    DbgInfoAvailable = UsesVAFloatArgument = UsesMorestackAddr = false; @@ -211,7 +215,6 @@ bool MachineModuleInfo::doInitialization(Module &M) {  }  bool MachineModuleInfo::doFinalization(Module &M) { -    Personalities.clear();    delete AddrLabelSymbols; @@ -290,10 +293,12 @@ void MachineModuleInfo::deleteMachineFunctionFor(Function &F) {  }  namespace { +  /// This pass frees the MachineFunction object associated with a Function.  class FreeMachineFunction : public FunctionPass {  public:    static char ID; +    FreeMachineFunction() : FunctionPass(ID) {}    void getAnalysisUsage(AnalysisUsage &AU) const override { @@ -311,14 +316,14 @@ public:      return "Free MachineFunction";    }   }; -char FreeMachineFunction::ID; +  } // end anonymous namespace -namespace llvm { -FunctionPass *createFreeMachineFunctionPass() { +char FreeMachineFunction::ID; + +FunctionPass *llvm::createFreeMachineFunctionPass() {    return new FreeMachineFunction();  } -} // end namespace llvm  //===- MMI building helpers -----------------------------------------------===//  | 
