Changeset View
Changeset View
Standalone View
Standalone View
llvm/lib/CodeGen/MachineModuleInfo.cpp
Show All 30 Lines | |||||
#include <cassert> | #include <cassert> | ||||
#include <memory> | #include <memory> | ||||
#include <utility> | #include <utility> | ||||
#include <vector> | #include <vector> | ||||
using namespace llvm; | using namespace llvm; | ||||
using namespace llvm::dwarf; | 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. | // Out of line virtual method. | ||||
MachineModuleInfoImpl::~MachineModuleInfoImpl() = default; | MachineModuleInfoImpl::~MachineModuleInfoImpl() = default; | ||||
namespace llvm { | namespace llvm { | ||||
class MMIAddrLabelMapCallbackPtr final : CallbackVH { | class MMIAddrLabelMapCallbackPtr final : CallbackVH { | ||||
MMIAddrLabelMap *Map = nullptr; | MMIAddrLabelMap *Map = nullptr; | ||||
▲ Show 20 Lines • Show All 136 Lines • ▼ Show 20 Lines | |||||
void MMIAddrLabelMapCallbackPtr::deleted() { | void MMIAddrLabelMapCallbackPtr::deleted() { | ||||
Map->UpdateForDeletedBlock(cast<BasicBlock>(getValPtr())); | Map->UpdateForDeletedBlock(cast<BasicBlock>(getValPtr())); | ||||
} | } | ||||
void MMIAddrLabelMapCallbackPtr::allUsesReplacedWith(Value *V2) { | void MMIAddrLabelMapCallbackPtr::allUsesReplacedWith(Value *V2) { | ||||
Map->UpdateForRAUWBlock(cast<BasicBlock>(getValPtr()), cast<BasicBlock>(V2)); | Map->UpdateForRAUWBlock(cast<BasicBlock>(getValPtr()), cast<BasicBlock>(V2)); | ||||
} | } | ||||
MachineModuleInfo::MachineModuleInfo(const LLVMTargetMachine *TM) | void MachineModuleInfo::initialize() { | ||||
: 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) { | |||||
ObjFileMMI = nullptr; | ObjFileMMI = nullptr; | ||||
CurCallSite = 0; | CurCallSite = 0; | ||||
UsesMSVCFloatingPoint = UsesMorestackAddr = false; | UsesMSVCFloatingPoint = UsesMorestackAddr = false; | ||||
HasSplitStack = HasNosplitStack = false; | HasSplitStack = HasNosplitStack = false; | ||||
AddrLabelSymbols = nullptr; | AddrLabelSymbols = nullptr; | ||||
TheModule = &M; | |||||
DbgInfoAvailable = !llvm::empty(M.debug_compile_units()); | |||||
return false; | |||||
} | } | ||||
bool MachineModuleInfo::doFinalization(Module &M) { | void MachineModuleInfo::finalize() { | ||||
Personalities.clear(); | Personalities.clear(); | ||||
delete AddrLabelSymbols; | delete AddrLabelSymbols; | ||||
AddrLabelSymbols = nullptr; | AddrLabelSymbols = nullptr; | ||||
Context.reset(); | Context.reset(); | ||||
delete ObjFileMMI; | delete ObjFileMMI; | ||||
ObjFileMMI = nullptr; | 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; | |||||
} | |||||
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 ----------------------------------------===// | //===- Address of Block Management ----------------------------------------===// | ||||
ArrayRef<MCSymbol *> | ArrayRef<MCSymbol *> | ||||
MachineModuleInfo::getAddrLabelSymbolToEmit(const BasicBlock *BB) { | MachineModuleInfo::getAddrLabelSymbolToEmit(const BasicBlock *BB) { | ||||
// Lazily create AddrLabelSymbols. | // Lazily create AddrLabelSymbols. | ||||
if (!AddrLabelSymbols) | if (!AddrLabelSymbols) | ||||
AddrLabelSymbols = new MMIAddrLabelMap(Context); | AddrLabelSymbols = new MMIAddrLabelMap(Context); | ||||
return AddrLabelSymbols->getAddrLabelSymbolToEmit(const_cast<BasicBlock*>(BB)); | return AddrLabelSymbols->getAddrLabelSymbolToEmit(const_cast<BasicBlock*>(BB)); | ||||
▲ Show 20 Lines • Show All 62 Lines • ▼ Show 20 Lines | |||||
/// This pass frees the MachineFunction object associated with a Function. | /// This pass frees the MachineFunction object associated with a Function. | ||||
class FreeMachineFunction : public FunctionPass { | class FreeMachineFunction : public FunctionPass { | ||||
public: | public: | ||||
static char ID; | static char ID; | ||||
FreeMachineFunction() : FunctionPass(ID) {} | FreeMachineFunction() : FunctionPass(ID) {} | ||||
void getAnalysisUsage(AnalysisUsage &AU) const override { | void getAnalysisUsage(AnalysisUsage &AU) const override { | ||||
AU.addRequired<MachineModuleInfo>(); | AU.addRequired<MachineModuleInfoWrapperPass>(); | ||||
AU.addPreserved<MachineModuleInfo>(); | AU.addPreserved<MachineModuleInfoWrapperPass>(); | ||||
} | } | ||||
bool runOnFunction(Function &F) override { | bool runOnFunction(Function &F) override { | ||||
MachineModuleInfo &MMI = getAnalysis<MachineModuleInfo>(); | MachineModuleInfo &MMI = | ||||
getAnalysis<MachineModuleInfoWrapperPass>().getMMI(); | |||||
MMI.deleteMachineFunctionFor(F); | MMI.deleteMachineFunctionFor(F); | ||||
return true; | return true; | ||||
} | } | ||||
StringRef getPassName() const override { | StringRef getPassName() const override { | ||||
return "Free MachineFunction"; | return "Free MachineFunction"; | ||||
} | } | ||||
}; | }; | ||||
} // end anonymous namespace | } // end anonymous namespace | ||||
char FreeMachineFunction::ID; | char FreeMachineFunction::ID; | ||||
FunctionPass *llvm::createFreeMachineFunctionPass() { | FunctionPass *llvm::createFreeMachineFunctionPass() { | ||||
return new FreeMachineFunction(); | 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()); | |||||
arsenm: I don't think you need the llvm:: | |||||
return MMI; | |||||
} |
I don't think you need the llvm::