42 "Machine Module Information",
false,
false)
63 void deleted()
override;
64 void allUsesReplacedWith(
Value *
V2)
override;
69 struct AddrLabelSymEntry {
81 std::vector<MMIAddrLabelMapCallbackPtr> BBCallbacks;
87 DeletedAddrLabelsNeedingEmission;
94 "Some labels for deleted blocks never got emitted");
99 void takeDeletedSymbolsForFunction(
Function *
F,
100 std::vector<MCSymbol*> &Result);
110 "Shouldn't get label for block without address taken");
111 AddrLabelSymEntry &Entry = AddrLabelSymbols[BB];
114 if (!Entry.Symbols.empty()) {
116 return Entry.Symbols;
121 BBCallbacks.emplace_back(BB);
122 BBCallbacks.back().setMap(
this);
123 Entry.Index = BBCallbacks.size() - 1;
125 Entry.Symbols.push_back(
Context.createTempSymbol());
126 return Entry.Symbols;
133 DeletedAddrLabelsNeedingEmission.find(F);
136 if (I == DeletedAddrLabelsNeedingEmission.
end())
return;
140 DeletedAddrLabelsNeedingEmission.erase(I);
147 AddrLabelSymEntry Entry = std::move(AddrLabelSymbols[BB]);
148 AddrLabelSymbols.erase(BB);
149 assert(!Entry.Symbols.empty() &&
"Didn't have a symbol, why a callback?");
150 BBCallbacks[Entry.Index] =
nullptr;
152 assert((BB->getParent() ==
nullptr || BB->getParent() == Entry.Fn) &&
153 "Block/parent mismatch");
155 for (
MCSymbol *Sym : Entry.Symbols) {
163 DeletedAddrLabelsNeedingEmission[Entry.Fn].push_back(Sym);
169 AddrLabelSymEntry OldEntry = std::move(AddrLabelSymbols[Old]);
170 AddrLabelSymbols.erase(Old);
171 assert(!OldEntry.Symbols.empty() &&
"Didn't have a symbol, why a callback?");
173 AddrLabelSymEntry &NewEntry = AddrLabelSymbols[New];
176 if (NewEntry.Symbols.empty()) {
177 BBCallbacks[OldEntry.Index].setPtr(New);
178 NewEntry = std::move(OldEntry);
182 BBCallbacks[OldEntry.Index] =
nullptr;
185 NewEntry.Symbols.insert(NewEntry.Symbols.end(), OldEntry.Symbols.begin(),
186 OldEntry.Symbols.end());
190 Map->UpdateForDeletedBlock(cast<BasicBlock>(getValPtr()));
194 Map->UpdateForRAUWBlock(cast<BasicBlock>(getValPtr()), cast<BasicBlock>(V2));
199 Context(TM->getMCAsmInfo(), TM->getMCRegisterInfo(),
200 TM->getObjFileLowering(), nullptr,
false) {
207 ObjFileMMI =
nullptr;
209 UsesVAFloatArgument = UsesMorestackAddr =
false;
210 HasSplitStack = HasNosplitStack =
false;
211 AddrLabelSymbols =
nullptr;
218 Personalities.clear();
220 delete AddrLabelSymbols;
221 AddrLabelSymbols =
nullptr;
226 ObjFileMMI =
nullptr;
236 if (!AddrLabelSymbols)
243 std::vector<MCSymbol*> &Result) {
245 if (!AddrLabelSymbols)
return;
246 return AddrLabelSymbols->
254 for (
unsigned i = 0; i < Personalities.size(); ++i)
255 if (Personalities[i] == Personality)
257 Personalities.push_back(Personality);
264 auto I = MachineFunctions.find(&F);
265 return I != MachineFunctions.end() ?
I->second.get() :
nullptr;
272 if (LastRequest == &F)
275 auto I = MachineFunctions.insert(
276 std::make_pair(&F, std::unique_ptr<MachineFunction>()));
283 I.first->second.reset(MF);
285 MF =
I.first->second.get();
294 MachineFunctions.erase(&F);
295 LastRequest =
nullptr;
296 LastResult =
nullptr;
320 return "Free MachineFunction";
329 return new FreeMachineFunction();
342 if (i->isFloatingPointTy()) {
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...
bool doFinalization(Module &) override
doFinalization - Virtual method overriden by subclasses to do any necessary clean up after all passes...
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...
void reset()
reset - return object to right after construction state to prepare to process a new module ...
This class represents a function call, abstracting a target machine's calling convention.
TinyPtrVector - This class is specialized for cases where there are normally 0 or 1 element in a vect...
virtual StringRef getPassName() const
getPassName - Return a nice clean name for a pass.
void computeUsesVAFloatArgument(const CallInst &I, MachineModuleInfo &MMI)
Determine if any floating-point values are being passed to this variadic function, and set the MachineModuleInfo's usesVAFloatArgument flag if so.
Value * getArgOperand(unsigned i) const
MachineModuleInfo(const LLVMTargetMachine *TM=nullptr)
void UpdateForRAUWBlock(BasicBlock *Old, BasicBlock *New)
AnalysisUsage & addRequired()
~MachineModuleInfo() override
MMIAddrLabelMap(MCContext &context)
Context object for machine code objects.
Class to represent function types.
virtual void getAnalysisUsage(AnalysisUsage &) const
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
Type * getType() const
All values are typed, get the type of this value.
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)
Value * getCalledValue() const
LLVM Basic Block Representation.
The instances of the Type class are immutable: once they are created, they are never changed...
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.
iterator_range< po_iterator< T > > post_order(const T &G)
MachineFunction & getOrCreateMachineFunction(const Function &F)
Returns the MachineFunction constructed for the IR function F.
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
constexpr bool empty(const T &RangeOrContainer)
Test whether RangeOrContainer is empty. Similar to C++17 std::empty.
void initializeMachineModuleInfoPass(PassRegistry &)
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)
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).
bool doInitialization(Module &) override
doInitialization - Virtual method overridden by subclasses to do any necessary initialization before ...
TargetSubtargetInfo - Generic base class for all target subtargets.
unsigned getNumArgOperands() const
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 setUsesVAFloatArgument(bool b)
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.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Value Representation.
void UpdateForDeletedBlock(BasicBlock *BB)
bool usesVAFloatArgument() const
Value handle with callbacks on RAUW and destruction.
StringRef - Represent a constant reference to a string, i.e.
void takeDeletedSymbolsForFunction(Function *F, std::vector< MCSymbol *> &Result)
If we have any deleted symbols for F, return them.
void setPtr(BasicBlock *BB)
This class can be derived from and used by targets to hold private target-specific information for ea...
Type * getContainedType(unsigned i) const
This method is used to implement the type iterator (defined at the end of the file).
This class contains meta information specific to a module.