27 using namespace llvm::dwarf;
31 "Machine Module Information",
false,
false)
50 void deleted()
override;
51 void allUsesReplacedWith(
Value *
V2)
override;
56 struct AddrLabelSymEntry {
68 std::vector<MMIAddrLabelMapCallbackPtr> BBCallbacks;
75 DeletedAddrLabelsNeedingEmission;
80 assert(DeletedAddrLabelsNeedingEmission.empty() &&
81 "Some labels for deleted blocks never got emitted");
86 void takeDeletedSymbolsForFunction(
Function *
F,
87 std::vector<MCSymbol*> &Result);
96 "Shouldn't get label for block without address taken");
97 AddrLabelSymEntry &Entry = AddrLabelSymbols[BB];
100 if (!Entry.Symbols.empty()) {
101 assert(BB->
getParent() == Entry.Fn &&
"Parent changed");
102 return Entry.Symbols;
107 BBCallbacks.emplace_back(BB);
108 BBCallbacks.back().setMap(
this);
109 Entry.Index = BBCallbacks.size() - 1;
111 Entry.Symbols.push_back(Context.createTempSymbol());
112 return Entry.Symbols;
120 DeletedAddrLabelsNeedingEmission.find(F);
123 if (I == DeletedAddrLabelsNeedingEmission.
end())
return;
127 DeletedAddrLabelsNeedingEmission.erase(I);
135 AddrLabelSymEntry Entry = std::move(AddrLabelSymbols[BB]);
136 AddrLabelSymbols.erase(BB);
137 assert(!Entry.Symbols.empty() &&
"Didn't have a symbol, why a callback?");
138 BBCallbacks[Entry.Index] =
nullptr;
140 assert((BB->getParent() ==
nullptr || BB->getParent() == Entry.Fn) &&
141 "Block/parent mismatch");
143 for (
MCSymbol *Sym : Entry.Symbols) {
151 DeletedAddrLabelsNeedingEmission[Entry.Fn].push_back(Sym);
157 AddrLabelSymEntry OldEntry = std::move(AddrLabelSymbols[Old]);
158 AddrLabelSymbols.erase(Old);
159 assert(!OldEntry.Symbols.empty() &&
"Didn't have a symbol, why a callback?");
161 AddrLabelSymEntry &NewEntry = AddrLabelSymbols[New];
164 if (NewEntry.Symbols.empty()) {
165 BBCallbacks[OldEntry.Index].setPtr(New);
166 NewEntry = std::move(OldEntry);
170 BBCallbacks[OldEntry.Index] =
nullptr;
173 NewEntry.Symbols.insert(NewEntry.Symbols.end(), OldEntry.Symbols.begin(),
174 OldEntry.Symbols.end());
179 Map->UpdateForDeletedBlock(cast<BasicBlock>(getValPtr()));
183 Map->UpdateForRAUWBlock(cast<BasicBlock>(getValPtr()), cast<BasicBlock>(V2));
198 llvm_unreachable(
"This MachineModuleInfo constructor should never be called, "
199 "MMI should always be explicitly constructed by "
200 "LLVMTargetMachine");
208 ObjFileMMI =
nullptr;
210 CallsEHReturn =
false;
211 CallsUnwindInit =
false;
212 DbgInfoAvailable = UsesVAFloatArgument = UsesMorestackAddr =
false;
214 Personalities.push_back(
nullptr);
216 AddrLabelSymbols =
nullptr;
224 Personalities.clear();
226 delete AddrLabelSymbols;
227 AddrLabelSymbols =
nullptr;
232 ObjFileMMI =
nullptr;
241 FrameInstructions.clear();
250 CallsEHReturn =
false;
251 CallsUnwindInit =
false;
263 if (!AddrLabelSymbols)
275 std::vector<MCSymbol*> &Result) {
277 if (!AddrLabelSymbols)
return;
278 return AddrLabelSymbols->
288 unsigned N = LandingPads.size();
289 for (
unsigned i = 0; i <
N; ++i) {
296 return LandingPads[
N];
314 return LandingPadLabel;
327 for (
unsigned i = 0; i < Personalities.size(); ++i)
328 if (Personalities[i] == Personality)
333 if (!Personalities[0])
334 Personalities[0] = Personality;
336 Personalities.push_back(Personality);
351 for (
unsigned N = TyInfo.
size();
N; --
N)
361 std::vector<unsigned> IdsInFilter(TyInfo.
size());
362 for (
unsigned I = 0, E = TyInfo.
size();
I != E; ++
I)
396 for (
unsigned i = 0; i != LandingPads.size(); ) {
406 LandingPads.erase(LandingPads.begin() + i);
410 for (
unsigned j = 0, e = LandingPads[i].BeginLabels.size(); j != e; ++j) {
414 (LPMap && (*LPMap)[BeginLabel] != 0)) &&
416 (LPMap && (*LPMap)[EndLabel] != 0)))
continue;
424 if (LandingPads[i].BeginLabels.empty()) {
425 LandingPads.erase(LandingPads.begin() + i);
442 LPadToCallSiteMap[Sym].append(Sites.
begin(), Sites.
end());
448 for (
unsigned i = 0,
N = TypeInfos.size(); i !=
N; ++i)
449 if (TypeInfos[i] == TI)
return i + 1;
451 TypeInfos.push_back(TI);
452 return TypeInfos.size();
461 for (std::vector<unsigned>::iterator
I = FilterEnds.begin(),
462 E = FilterEnds.end();
I != E; ++
I) {
463 unsigned i = *
I, j = TyIds.size();
466 if (FilterIds[--i] != TyIds[--j])
477 int FilterID = -(1 + FilterIds.size());
478 FilterIds.reserve(FilterIds.size() + TyIds.size() + 1);
479 FilterIds.insert(FilterIds.end(), TyIds.begin(), TyIds.end());
480 FilterEnds.push_back(FilterIds.size());
481 FilterIds.push_back(0);
489 return LPI.Personality;
498 return PersonalityTypeCache;
504 const Function* Personality =
nullptr;
507 for (
unsigned i = 0, e = LandingPads.size(); i != e; ++i)
508 if (LandingPads[i].Personality) {
509 Personality = LandingPads[i].Personality;
513 for (
unsigned i = 0, e = Personalities.size(); i < e; ++i) {
514 if (Personalities[i] == Personality)
526 if (WinEHParentName.
empty() || WinEHParentName == F->
getName())
unsigned getTypeIDFor(const GlobalValue *TI)
getTypeIDFor - Return the type id for the specified typeinfo.
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. ...
WinEHFuncInfo & getWinEHFuncInfo(const Function *F)
void setCallSiteLandingPad(MCSymbol *Sym, ArrayRef< unsigned > Sites)
setCallSiteLandingPad - Map the landing pad's EH symbol to the call site indexes. ...
const Function * FilterOrFinally
void reset()
reset - return object to right after construction state to prepare to process a new module ...
const Function * Personality
const Function * getParent() const
Return the enclosing method, or null if none.
Attribute getFnAttribute(Attribute::AttrKind Kind) const
Return the attribute for the given attribute kind.
MCSymbol * LandingPadLabel
TinyPtrVector - This class is specialized for cases where there are normally 0 or 1 element in a vect...
StringRef getName() const
Return a constant reference to the value's name.
void UpdateForRAUWBlock(BasicBlock *Old, BasicBlock *New)
BlockAddress - The address of a basic block.
void takeDeletedSymbolsForFunction(const Function *F, std::vector< MCSymbol * > &Result)
takeDeletedSymbolsForFunction - If the specified function has had any references to address-taken blo...
SmallVector< MCSymbol *, 1 > EndLabels
~MachineModuleInfo() override
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
SmallVector< SEHHandler, 1 > SEHHandlers
bool hasAddressTaken() const
Returns true if there are any uses of this basic block other than direct branches, switches, etc.
MMIAddrLabelMap(MCContext &context)
Context object for machine code objects.
LandingPadInfo - This structure is used to retain landing pad info for the current function...
LandingPadInfo & getOrCreateLandingPadInfo(MachineBasicBlock *LandingPad)
getOrCreateLandingPadInfo - Find or create an LandingPadInfo for the specified MachineBasicBlock.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
void addPersonality(MachineBasicBlock *LandingPad, const Function *Personality)
addPersonality - Provide the personality function for the exception information.
ArrayRef< MCSymbol * > getAddrLabelSymbolToEmit(const BasicBlock *BB)
getAddrLabelSymbolToEmit - Return the symbol to be used for the specified basic block when its addres...
size_t size() const
size - Get the array size.
void addFilterTypeInfo(MachineBasicBlock *LandingPad, ArrayRef< const GlobalValue * > TyInfo)
addFilterTypeInfo - Provide the filter typeinfo for a landing pad.
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
Function * getFunction(StringRef Name) const
Look up the specified function in the module symbol table.
This class is intended to be used as a base class for asm properties and features specific to the tar...
MCSymbol * createTempSymbol(bool CanBeUnnamed=true)
Create and return a new assembler temporary symbol with a unique but unspecified name.
LLVM Basic Block Representation.
void addCatchTypeInfo(MachineBasicBlock *LandingPad, ArrayRef< const GlobalValue * > TyInfo)
addCatchTypeInfo - Provide the catch typeinfo for a landing pad.
SmallVector< MCSymbol *, 1 > BeginLabels
This file contains the declarations for the subclasses of Constant, which represent the different fla...
EHPersonality getPersonalityType()
Classify the personality function amongst known EH styles.
EHPersonality classifyEHPersonality(const Value *Pers)
See if the given exception handling personality function is one that we understand.
void takeDeletedSymbolsForFunction(Function *F, std::vector< MCSymbol * > &Result)
takeDeletedSymbolsForFunction - If we have any deleted symbols for F, return them.
std::vector< int > TypeIds
VariableDbgInfoMapTy VariableDbgInfos
MCSymbol * addLandingPad(MachineBasicBlock *LandingPad)
addLandingPad - Add a new panding pad.
void addInvoke(MachineBasicBlock *LandingPad, MCSymbol *BeginLabel, MCSymbol *EndLabel)
addInvoke - Provide the begin and end labels of an invoke style call and associate it with a try land...
MMIAddrLabelMapCallbackPtr()
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
void initializeMachineModuleInfoPass(PassRegistry &)
bool isDefined() const
isDefined - Check if this symbol is defined (i.e., it has an address).
void addSEHCatchHandler(MachineBasicBlock *LandingPad, const Function *Filter, const BlockAddress *RecoverLabel)
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)
void addSEHCleanupHandler(MachineBasicBlock *LandingPad, const Function *Cleanup)
void addCleanup(MachineBasicBlock *LandingPad)
addCleanup - Add a cleanup action for a landing pad.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
MMIAddrLabelMapCallbackPtr(Value *V)
void addWinEHState(MachineBasicBlock *LandingPad, int State)
MachineBasicBlock * LandingPadBlock
bool doInitialization(Module &) override
doInitialization - Virtual method overridden by subclasses to do any necessary initialization before ...
const Function * getWinEHParent(const Function *F) const
int getFilterIDFor(std::vector< unsigned > &TyIds)
getFilterIDFor - Return the id of the filter encoded by TyIds.
unsigned getPersonalityIndex() const
getPersonalityIndex - Get index of the current personality function inside Personalitites array ...
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.
StringRef getValueAsString() const
Return the attribute's value as a string.
void TidyLandingPads(DenseMap< MCSymbol *, uintptr_t > *LPMap=nullptr)
TidyLandingPads - Remap landing pad labels and remove any deleted landing pads.
Module * getParent()
Get the module that this global value is contained inside of...
LLVM Value Representation.
const BlockAddress * RecoverBA
void UpdateForDeletedBlock(BasicBlock *BB)
Value handle with callbacks on RAUW and destruction.
StringRef - Represent a constant reference to a string, i.e.
void setPtr(BasicBlock *BB)
void EndFunction()
EndFunction - Discard function meta information.
MachineModuleInfoImpl - This class can be derived from and used by targets to hold private target-spe...
MachineModuleInfo - This class contains meta information specific to a module.
bool empty() const
empty - Check if the string is empty.
const Function * getPersonality() const
getPersonality - Return a personality function if available.