32 using namespace llvm::dwarf;
36 "Machine Module Information",
false,
false)
55 void deleted()
override;
56 void allUsesReplacedWith(
Value *
V2)
override;
61 struct AddrLabelSymEntry {
73 std::vector<MMIAddrLabelMapCallbackPtr> BBCallbacks;
79 DeletedAddrLabelsNeedingEmission;
84 assert(DeletedAddrLabelsNeedingEmission.empty() &&
85 "Some labels for deleted blocks never got emitted");
90 void takeDeletedSymbolsForFunction(
Function *
F,
91 std::vector<MCSymbol*> &Result);
100 "Shouldn't get label for block without address taken");
101 AddrLabelSymEntry &Entry = AddrLabelSymbols[BB];
104 if (!Entry.Symbols.empty()) {
106 return Entry.Symbols;
111 BBCallbacks.emplace_back(BB);
112 BBCallbacks.back().setMap(
this);
113 Entry.Index = BBCallbacks.size() - 1;
115 Entry.Symbols.push_back(
Context.createTempSymbol());
116 return Entry.Symbols;
123 DeletedAddrLabelsNeedingEmission.find(F);
126 if (I == DeletedAddrLabelsNeedingEmission.
end())
return;
130 DeletedAddrLabelsNeedingEmission.erase(I);
138 AddrLabelSymEntry Entry = std::move(AddrLabelSymbols[BB]);
139 AddrLabelSymbols.erase(BB);
140 assert(!Entry.Symbols.empty() &&
"Didn't have a symbol, why a callback?");
141 BBCallbacks[Entry.Index] =
nullptr;
143 assert((BB->getParent() ==
nullptr || BB->getParent() == Entry.Fn) &&
144 "Block/parent mismatch");
146 for (
MCSymbol *Sym : Entry.Symbols) {
154 DeletedAddrLabelsNeedingEmission[Entry.Fn].push_back(Sym);
160 AddrLabelSymEntry OldEntry = std::move(AddrLabelSymbols[Old]);
161 AddrLabelSymbols.erase(Old);
162 assert(!OldEntry.Symbols.empty() &&
"Didn't have a symbol, why a callback?");
164 AddrLabelSymEntry &NewEntry = AddrLabelSymbols[New];
167 if (NewEntry.Symbols.empty()) {
168 BBCallbacks[OldEntry.Index].setPtr(New);
169 NewEntry = std::move(OldEntry);
173 BBCallbacks[OldEntry.Index] =
nullptr;
176 NewEntry.Symbols.insert(NewEntry.Symbols.end(), OldEntry.Symbols.begin(),
177 OldEntry.Symbols.end());
182 Map->UpdateForDeletedBlock(cast<BasicBlock>(getValPtr()));
186 Map->UpdateForRAUWBlock(cast<BasicBlock>(getValPtr()), cast<BasicBlock>(V2));
194 Context(TM->getMCAsmInfo(), TM->getMCRegisterInfo(),
195 TM->getObjFileLowering(), nullptr,
false) {
204 ObjFileMMI =
nullptr;
206 DbgInfoAvailable = UsesVAFloatArgument = UsesMorestackAddr =
false;
207 AddrLabelSymbols =
nullptr;
215 Personalities.clear();
217 delete AddrLabelSymbols;
218 AddrLabelSymbols =
nullptr;
223 ObjFileMMI =
nullptr;
233 if (!AddrLabelSymbols)
240 std::vector<MCSymbol*> &Result) {
242 if (!AddrLabelSymbols)
return;
243 return AddrLabelSymbols->
251 for (
unsigned i = 0;
i < Personalities.size(); ++
i)
252 if (Personalities[
i] == Personality)
254 Personalities.push_back(Personality);
262 if (LastRequest == &F)
265 auto I = MachineFunctions.insert(
266 std::make_pair(&F, std::unique_ptr<MachineFunction>()));
272 I.first->second.reset(MF);
278 MF =
I.first->second.get();
287 MachineFunctions.erase(&F);
288 LastRequest =
nullptr;
289 LastResult =
nullptr;
304 bool runOnFunction(
Function &
F)
override {
315 return new FreeMachineFunction();
329 if (
i->isFloatingPointTy()) {
const Value * getCalledValue() const
Get a pointer to the function that is invoked by this instruction.
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...
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
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.
const Function * getParent() const
Return the enclosing method, or null if none.
TinyPtrVector - This class is specialized for cases where there are normally 0 or 1 element in a vect...
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.
void UpdateForRAUWBlock(BasicBlock *Old, BasicBlock *New)
AnalysisUsage & addRequired()
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.
~MachineModuleInfo() override
unsigned getNumArgOperands() const
Return the number of call arguments.
bool hasAddressTaken() const
Returns true if there are any uses of this basic block other than direct branches, switches, etc.
MachineModuleInfo(const TargetMachine *TM=nullptr)
bool usesVAFloatArgument() const
MMIAddrLabelMap(MCContext &context)
Context object for machine code objects.
Class to represent function types.
Function Alias Analysis false
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.
MachineFunction & getMachineFunction(const Function &F)
Returns the MachineFunction constructed for the IR function F.
LLVM Basic Block Representation.
The instances of the Type class are immutable: once they are created, they are never changed...
Type * getContainedType(unsigned i) const
This method is used to implement the type iterator (defined at the end of the file).
void addPersonality(const Function *Personality)
Provide the personality function for the exception information.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
FunctionPass * createFreeMachineFunctionPass()
This pass frees the memory occupied by the MachineFunction.
Represent the analysis usage information of a pass.
void takeDeletedSymbolsForFunction(Function *F, std::vector< MCSymbol * > &Result)
If we have any deleted symbols for F, return them.
FunctionPass class - This class is used to implement most global optimizations.
iterator_range< po_iterator< T > > post_order(const T &G)
MMIAddrLabelMapCallbackPtr()
void initializeMachineModuleInfoPass(PassRegistry &)
#define INITIALIZE_TM_PASS(passName, arg, name, cfg, analysis)
This initializer registers TargetMachine constructor, so the pass being initialized can use target de...
ImmutablePass class - This class is used to provide information that does not need to be run...
Module.h This file contains the declarations for the Module class.
void setMap(MMIAddrLabelMap *map)
Type * getType() const
All values are typed, get the type of this value.
virtual bool initializeMachineFunction(MachineFunction &MF)=0
Initialize the machine function.
bool isDefined(bool SetUsed=true) const
isDefined - Check if this symbol is defined (i.e., it has an address).
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
Value * getArgOperand(unsigned i) const
getArgOperand/setArgOperand - Return/set the i-th call argument.
MMIAddrLabelMapCallbackPtr(Value *V)
bool doInitialization(Module &) override
doInitialization - Virtual method overridden by subclasses to do any necessary initialization before ...
void setUsesVAFloatArgument(bool b)
void allUsesReplacedWith(Value *V2) override
Callback for Value RAUW.
Value * operator=(Value *RHS)
ArrayRef< MCSymbol * > getAddrLabelSymbolToEmit(BasicBlock *BB)
void deleted() override
Callback for Value destruction.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Value Representation.
void UpdateForDeletedBlock(BasicBlock *BB)
Primary interface to the complete machine description for the target machine.
Value handle with callbacks on RAUW and destruction.
void setPtr(BasicBlock *BB)
This class can be derived from and used by targets to hold private target-specific information for ea...
This class contains meta information specific to a module.