59 void deleted()
override;
60 void allUsesReplacedWith(
Value *
V2)
override;
65 struct AddrLabelSymEntry {
77 std::vector<MMIAddrLabelMapCallbackPtr> BBCallbacks;
83 DeletedAddrLabelsNeedingEmission;
90 "Some labels for deleted blocks never got emitted");
95 void takeDeletedSymbolsForFunction(
Function *
F,
96 std::vector<MCSymbol*> &Result);
106 "Shouldn't get label for block without address taken");
107 AddrLabelSymEntry &
Entry = AddrLabelSymbols[BB];
110 if (!Entry.Symbols.empty()) {
112 return Entry.Symbols;
117 BBCallbacks.emplace_back(BB);
118 BBCallbacks.back().setMap(
this);
119 Entry.Index = BBCallbacks.size() - 1;
122 if (
Context.getObjectFileInfo()->getTargetTriple().isOSBinFormatXCOFF()) {
124 Context.lookupSymbol(
"." + Entry.Fn->getName());
125 assert(FnEntryPointSym &&
"The function entry pointer symbol should have" 126 " already been initialized.");
128 cast<MCSymbolXCOFF>(FnEntryPointSym)->getContainingCsect();
129 cast<MCSymbolXCOFF>(Sym)->setContainingCsect(Csect);
131 Entry.Symbols.push_back(Sym);
132 return Entry.Symbols;
139 DeletedAddrLabelsNeedingEmission.find(F);
142 if (I == DeletedAddrLabelsNeedingEmission.
end())
return;
146 DeletedAddrLabelsNeedingEmission.erase(I);
153 AddrLabelSymEntry
Entry = std::move(AddrLabelSymbols[BB]);
154 AddrLabelSymbols.erase(BB);
155 assert(!Entry.Symbols.empty() &&
"Didn't have a symbol, why a callback?");
156 BBCallbacks[Entry.Index] =
nullptr;
158 assert((BB->getParent() ==
nullptr || BB->getParent() == Entry.Fn) &&
159 "Block/parent mismatch");
161 for (
MCSymbol *Sym : Entry.Symbols) {
169 DeletedAddrLabelsNeedingEmission[Entry.Fn].push_back(Sym);
175 AddrLabelSymEntry OldEntry = std::move(AddrLabelSymbols[Old]);
176 AddrLabelSymbols.erase(Old);
177 assert(!OldEntry.Symbols.empty() &&
"Didn't have a symbol, why a callback?");
179 AddrLabelSymEntry &NewEntry = AddrLabelSymbols[New];
182 if (NewEntry.Symbols.empty()) {
183 BBCallbacks[OldEntry.Index].setPtr(New);
184 NewEntry = std::move(OldEntry);
188 BBCallbacks[OldEntry.Index] =
nullptr;
191 NewEntry.Symbols.insert(NewEntry.Symbols.end(), OldEntry.Symbols.begin(),
192 OldEntry.Symbols.end());
196 Map->UpdateForDeletedBlock(cast<BasicBlock>(getValPtr()));
200 Map->UpdateForRAUWBlock(cast<BasicBlock>(getValPtr()), cast<BasicBlock>(V2));
204 ObjFileMMI =
nullptr;
206 UsesMSVCFloatingPoint = UsesMorestackAddr =
false;
207 HasSplitStack = HasNosplitStack =
false;
208 AddrLabelSymbols =
nullptr;
212 Personalities.clear();
214 delete AddrLabelSymbols;
215 AddrLabelSymbols =
nullptr;
220 ObjFileMMI =
nullptr;
225 Context(MMI.
TM.getMCAsmInfo(), MMI.
TM.getMCRegisterInfo(),
226 MMI.
TM.getObjFileLowering(), nullptr, nullptr,
false) {
227 ObjFileMMI = MMI.ObjFileMMI;
228 CurCallSite = MMI.CurCallSite;
229 UsesMSVCFloatingPoint = MMI.UsesMSVCFloatingPoint;
230 UsesMorestackAddr = MMI.UsesMorestackAddr;
231 HasSplitStack = MMI.HasSplitStack;
232 HasNosplitStack = MMI.HasNosplitStack;
233 AddrLabelSymbols = MMI.AddrLabelSymbols;
234 TheModule = MMI.TheModule;
238 : TM(*TM), Context(TM->getMCAsmInfo(), TM->getMCRegisterInfo(),
239 TM->getObjFileLowering(), nullptr, nullptr,
false) {
250 if (!AddrLabelSymbols)
257 std::vector<MCSymbol*> &Result) {
259 if (!AddrLabelSymbols)
return;
260 return AddrLabelSymbols->
268 for (
unsigned i = 0; i < Personalities.size(); ++i)
269 if (Personalities[i] == Personality)
271 Personalities.push_back(Personality);
278 auto I = MachineFunctions.find(&F);
279 return I != MachineFunctions.end() ?
I->second.get() :
nullptr;
286 if (LastRequest == &F)
289 auto I = MachineFunctions.insert(
290 std::make_pair(&F, std::unique_ptr<MachineFunction>()));
297 I.first->second.reset(MF);
299 MF =
I.first->second.get();
308 MachineFunctions.erase(&F);
309 LastRequest =
nullptr;
310 LastResult =
nullptr;
329 getAnalysis<MachineModuleInfoWrapperPass>().getMMI();
335 return "Free MachineFunction";
344 return new FreeMachineFunction();
355 "Machine Module Information",
false,
false)
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
This class represents lattice values for constants.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
A Module instance is used to store all the information related to an LLVM module. ...
void deleteMachineFunctionFor(Function &F)
Delete the MachineFunction MF and reset the link in the IR Function to Machine Function map...
TinyPtrVector - This class is specialized for cases where there are normally 0 or 1 element in a vect...
MachineModuleInfo(const LLVMTargetMachine *TM=nullptr)
MachineModuleInfo run(Module &M, ModuleAnalysisManager &)
Run the analysis pass and produce machine module information.
void UpdateForRAUWBlock(BasicBlock *Old, BasicBlock *New)
AnalysisUsage & addRequired()
MachineModuleInfoWrapperPass(const LLVMTargetMachine *TM=nullptr)
MMIAddrLabelMap(MCContext &context)
Context object for machine code objects.
virtual ~MachineModuleInfoImpl()
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
ArrayRef< MCSymbol * > getAddrLabelSymbolToEmit(const BasicBlock *BB)
Return the symbol to be used for the specified basic block when its address is taken.
static bool runOnFunction(Function &F, bool PostInlining)
LLVM Basic Block Representation.
void takeDeletedSymbolsForFunction(const Function *F, std::vector< MCSymbol *> &Result)
If the specified function has had any references to address-taken blocks generated, but the block got deleted, return the symbol now so we can emit it.
void addPersonality(const Function *Personality)
Provide the personality function for the exception information.
FunctionPass * createFreeMachineFunctionPass()
This pass frees the memory occupied by the MachineFunction.
Represent the analysis usage information of a pass.
This class describes a target machine that is implemented with the LLVM target-independent code gener...
FunctionPass class - This class is used to implement most global optimizations.
MachineFunction & getOrCreateMachineFunction(const Function &F)
Returns the MachineFunction constructed for the IR function F.
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
bool hasAddressTaken() const
Returns true if there are any uses of this basic block other than direct branches, switches, etc.
ImmutablePass class - This class is used to provide information that does not need to be run...
MachineFunction * getMachineFunction(const Function &F) const
Returns the MachineFunction associated to IR function F if there is one, otherwise nullptr...
Module.h This file contains the declarations for the Module class.
void setMap(MMIAddrLabelMap *map)
void initializeMachineModuleInfoWrapperPassPass(PassRegistry &)
virtual const TargetSubtargetInfo * getSubtargetImpl(const Function &) const
Virtual method implemented by subclasses that returns a reference to that target's TargetSubtargetInf...
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
MMIAddrLabelMapCallbackPtr(Value *V)
bool isDefined() const
isDefined - Check if this symbol is defined (i.e., it has an address).
TargetSubtargetInfo - Generic base class for all target subtargets.
const Function * getParent() const
Return the enclosing method, or null if none.
iterator_range< debug_compile_units_iterator > debug_compile_units() const
Return an iterator for all DICompileUnits listed in this Module's llvm.dbg.cu named metadata node and...
void allUsesReplacedWith(Value *V2) override
Callback for Value RAUW.
Value * operator=(Value *RHS)
ArrayRef< MCSymbol * > getAddrLabelSymbolToEmit(BasicBlock *BB)
LLVM_NODISCARD bool empty() const
void deleted() override
Callback for Value destruction.
bool doInitialization(Module &) override
doInitialization - Virtual method overridden by subclasses to do any necessary initialization before ...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Value Representation.
bool doFinalization(Module &) override
doFinalization - Virtual method overriden by subclasses to do any necessary clean up after all passes...
void UpdateForDeletedBlock(BasicBlock *BB)
Value handle with callbacks on RAUW and destruction.
StringRef - Represent a constant reference to a string, i.e.
A container for analyses that lazily runs them and caches their results.
void takeDeletedSymbolsForFunction(Function *F, std::vector< MCSymbol *> &Result)
If we have any deleted symbols for F, return them.
void setPtr(BasicBlock *BB)
A special type used by analysis passes to provide an address that identifies that particular analysis...
This class contains meta information specific to a module.