38 using namespace llvm::dwarf;
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;
93 assert(DeletedAddrLabelsNeedingEmission.empty() &&
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 DbgInfoAvailable = UsesVAFloatArgument = UsesMorestackAddr =
false;
210 AddrLabelSymbols =
nullptr;
217 Personalities.clear();
219 delete AddrLabelSymbols;
220 AddrLabelSymbols =
nullptr;
225 ObjFileMMI =
nullptr;
235 if (!AddrLabelSymbols)
242 std::vector<MCSymbol*> &Result) {
244 if (!AddrLabelSymbols)
return;
245 return AddrLabelSymbols->
253 for (
unsigned i = 0; i < Personalities.size(); ++i)
254 if (Personalities[i] == Personality)
256 Personalities.push_back(Personality);
263 auto I = MachineFunctions.find(&F);
264 return I != MachineFunctions.end() ?
I->second.get() :
nullptr;
271 if (LastRequest == &F)
274 auto I = MachineFunctions.insert(
275 std::make_pair(&F, std::unique_ptr<MachineFunction>()));
281 I.first->second.reset(MF);
283 MF =
I.first->second.get();
292 MachineFunctions.erase(&F);
293 LastRequest =
nullptr;
294 LastResult =
nullptr;
311 bool runOnFunction(
Function &
F)
override {
318 return "Free MachineFunction";
327 return new FreeMachineFunction();
340 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...
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.
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.
Function Alias Analysis false
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.
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)
MachineFunction & getOrCreateMachineFunction(const Function &F)
Returns the MachineFunction constructed for the IR function F.
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
void initializeMachineModuleInfoPass(PassRegistry &)
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.
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)
MachineFunction * getMachineFunction(const Function &F) const
Returns the MachineFunction associated to IR function F if there is one, otherwise nullptr...
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.
StringRef - Represent a constant reference to a string, i.e.
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.