25 using namespace llvm::dwarf;
29 "Machine Module Information",
false,
false)
48 virtual void deleted();
49 virtual void allUsesReplacedWith(
Value *
V2);
54 struct AddrLabelSymEntry {
67 std::vector<MMIAddrLabelMapCallbackPtr> BBCallbacks;
74 DeletedAddrLabelsNeedingEmission;
79 assert(DeletedAddrLabelsNeedingEmission.empty() &&
80 "Some labels for deleted blocks never got emitted");
84 I = AddrLabelSymbols.begin(), E = AddrLabelSymbols.end();
I != E; ++
I)
85 if (
I->second.Symbols.is<std::vector<MCSymbol*>*>())
86 delete I->second.Symbols.get<std::vector<MCSymbol*>*>();
90 std::vector<MCSymbol*> getAddrLabelSymbolToEmit(
BasicBlock *BB);
92 void takeDeletedSymbolsForFunction(
Function *
F,
93 std::vector<MCSymbol*> &Result);
102 "Shouldn't get label for block without address taken");
103 AddrLabelSymEntry &Entry = AddrLabelSymbols[BB];
106 if (!Entry.Symbols.isNull()) {
107 assert(BB->
getParent() == Entry.Fn &&
"Parent changed");
109 return Entry.Symbols.get<
MCSymbol*>();
110 return (*Entry.Symbols.get<std::vector<MCSymbol*>*>())[0];
115 BBCallbacks.push_back(BB);
116 BBCallbacks.back().setMap(
this);
117 Entry.Index = BBCallbacks.size()-1;
119 MCSymbol *Result = Context.CreateTempSymbol();
120 Entry.Symbols = Result;
124 std::vector<MCSymbol*>
127 "Shouldn't get label for block without address taken");
128 AddrLabelSymEntry &Entry = AddrLabelSymbols[BB];
130 std::vector<MCSymbol*> Result;
133 if (Entry.Symbols.isNull())
134 Result.push_back(getAddrLabelSymbol(BB));
136 Result.push_back(Sym);
138 Result = *Entry.Symbols.get<std::vector<MCSymbol*>*>();
148 DeletedAddrLabelsNeedingEmission.find(F);
151 if (I == DeletedAddrLabelsNeedingEmission.
end())
return;
155 DeletedAddrLabelsNeedingEmission.erase(I);
163 AddrLabelSymEntry Entry = AddrLabelSymbols[BB];
164 AddrLabelSymbols.erase(BB);
165 assert(!Entry.Symbols.isNull() &&
"Didn't have a symbol, why a callback?");
166 BBCallbacks[Entry.Index] = 0;
169 "Block/parent mismatch");
173 if (Sym->isDefined())
180 DeletedAddrLabelsNeedingEmission[Entry.Fn].push_back(Sym);
182 std::vector<MCSymbol*> *Syms = Entry.Symbols.get<std::vector<MCSymbol*>*>();
184 for (
unsigned i = 0, e = Syms->size(); i != e; ++i) {
193 DeletedAddrLabelsNeedingEmission[Entry.Fn].push_back(Sym);
203 AddrLabelSymEntry OldEntry = AddrLabelSymbols[Old];
204 AddrLabelSymbols.erase(Old);
205 assert(!OldEntry.Symbols.isNull() &&
"Didn't have a symbol, why a callback?");
207 AddrLabelSymEntry &NewEntry = AddrLabelSymbols[New];
210 if (NewEntry.Symbols.isNull()) {
211 BBCallbacks[OldEntry.Index].setPtr(New);
216 BBCallbacks[OldEntry.Index] = 0;
221 std::vector<MCSymbol*> *SymList =
new std::vector<MCSymbol*>();
222 SymList->push_back(PrevSym);
223 NewEntry.Symbols = SymList;
226 std::vector<MCSymbol*> *SymList =
227 NewEntry.Symbols.get<std::vector<MCSymbol*>*>();
231 SymList->push_back(Sym);
236 std::vector<MCSymbol*> *Syms =OldEntry.Symbols.get<std::vector<MCSymbol*>*>();
237 SymList->insert(SymList->end(), Syms->begin(), Syms->end());
243 Map->UpdateForDeletedBlock(cast<BasicBlock>(getValPtr()));
247 Map->UpdateForRAUWBlock(cast<BasicBlock>(getValPtr()), cast<BasicBlock>(V2));
262 llvm_unreachable(
"This MachineModuleInfo constructor should never be called, "
263 "MMI should always be explicitly constructed by "
264 "LLVMTargetMachine");
273 CompactUnwindEncoding = 0;
277 DbgInfoAvailable = UsesVAFloatArgument =
false;
279 Personalities.push_back(NULL);
280 AddrLabelSymbols = 0;
288 Personalities.clear();
290 delete AddrLabelSymbols;
291 AddrLabelSymbols = 0;
305 FrameInstructions.clear();
315 CompactUnwindEncoding = 0;
333 UsedFunctions.insert(
F);
344 if (AddrLabelSymbols == 0)
355 if (AddrLabelSymbols == 0)
367 std::vector<MCSymbol*> &Result) {
369 if (AddrLabelSymbols == 0)
return;
370 return AddrLabelSymbols->
380 unsigned N = LandingPads.size();
381 for (
unsigned i = 0; i <
N; ++i) {
388 return LandingPads[
N];
406 return LandingPadLabel;
416 for (
unsigned i = 0; i < Personalities.size(); ++i)
417 if (Personalities[i] == Personality)
422 if (Personalities[0] == NULL)
423 Personalities[0] = Personality;
425 Personalities.push_back(Personality);
434 for (
unsigned N = TyInfo.
size();
N; --
N)
444 std::vector<unsigned> IdsInFilter(TyInfo.
size());
445 for (
unsigned I = 0, E = TyInfo.
size();
I != E; ++
I)
460 for (
unsigned i = 0; i != LandingPads.size(); ) {
470 LandingPads.erase(LandingPads.begin() + i);
474 for (
unsigned j = 0, e = LandingPads[i].BeginLabels.size(); j != e; ++j) {
478 (LPMap && (*LPMap)[BeginLabel] != 0)) &&
480 (LPMap && (*LPMap)[EndLabel] != 0)))
continue;
488 if (LandingPads[i].BeginLabels.empty()) {
489 LandingPads.erase(LandingPads.begin() + i);
506 LPadToCallSiteMap[Sym].append(Sites.
begin(), Sites.
end());
512 for (
unsigned i = 0,
N = TypeInfos.size(); i !=
N; ++i)
513 if (TypeInfos[i] == TI)
return i + 1;
515 TypeInfos.push_back(TI);
516 return TypeInfos.size();
525 for (std::vector<unsigned>::iterator
I = FilterEnds.begin(),
526 E = FilterEnds.end();
I != E; ++
I) {
527 unsigned i = *
I, j = TyIds.size();
530 if (FilterIds[--i] != TyIds[--j])
541 int FilterID = -(1 + FilterIds.size());
542 FilterIds.reserve(FilterIds.size() + TyIds.size() + 1);
543 FilterIds.insert(FilterIds.end(), TyIds.begin(), TyIds.end());
544 FilterEnds.push_back(FilterIds.size());
545 FilterIds.push_back(0);
553 return !LandingPads.empty() ? LandingPads[0].Personality : NULL;
562 for (
unsigned i = 0, e = LandingPads.size(); i != e; ++i)
563 if (LandingPads[i].Personality) {
564 Personality = LandingPads[i].Personality;
568 for (
unsigned i = 0, e = Personalities.size(); i < e; ++i) {
569 if (Personalities[i] == Personality)
virtual void allUsesReplacedWith(Value *V2)
std::vector< MCSymbol * > getAddrLabelSymbolToEmit(const BasicBlock *BB)
static PassRegistry * getPassRegistry()
MCSymbol * getAddrLabelSymbol(BasicBlock *BB)
The main container class for the LLVM Intermediate Representation.
void setCallSiteLandingPad(MCSymbol *Sym, ArrayRef< unsigned > Sites)
unsigned getNumOperands() const
const Function * Personality
const Function * getParent() const
Return the enclosing method, or null if none.
MCSymbol * LandingPadLabel
const Constant * getInitializer() const
const GlobalVariable * getGlobalVariable(StringRef Name, bool AllowInternal=false) const
MCSymbol * getAddrLabelSymbol(const BasicBlock *BB)
virtual bool doFinalization(Module &)
void UpdateForRAUWBlock(BasicBlock *Old, BasicBlock *New)
SmallVector< MCSymbol *, 1 > BeginLabels
MCSymbol * CreateTempSymbol()
void takeDeletedSymbolsForFunction(const Function *F, std::vector< MCSymbol * > &Result)
#define llvm_unreachable(msg)
bool hasAddressTaken() const
Returns true if there are any uses of this basic block other than direct branches, switches, etc. to it.
void TidyLandingPads(DenseMap< MCSymbol *, uintptr_t > *LPMap=0)
ID
LLVM Calling Convention Representation.
MMIAddrLabelMap(MCContext &context)
LandingPadInfo & getOrCreateLandingPadInfo(MachineBasicBlock *LandingPad)
void addPersonality(MachineBasicBlock *LandingPad, const Function *Personality)
size_t size() const
size - Get the array size.
std::vector< MCSymbol * > getAddrLabelSymbolToEmit(BasicBlock *BB)
void AnalyzeModule(const Module &M)
LLVM Basic Block Representation.
SmallVector< MCSymbol *, 1 > EndLabels
void takeDeletedSymbolsForFunction(Function *F, std::vector< MCSymbol * > &Result)
std::vector< int > TypeIds
Value * getOperand(unsigned i) const
MCSymbol * addLandingPad(MachineBasicBlock *LandingPad)
void addInvoke(MachineBasicBlock *LandingPad, MCSymbol *BeginLabel, MCSymbol *EndLabel)
unsigned getTypeIDFor(const GlobalVariable *TI)
MMIAddrLabelMapCallbackPtr()
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
void initializeMachineModuleInfoPass(PassRegistry &)
void setMap(MMIAddrLabelMap *map)
void addCatchTypeInfo(MachineBasicBlock *LandingPad, ArrayRef< const GlobalVariable * > TyInfo)
void addCleanup(MachineBasicBlock *LandingPad)
Value * stripPointerCasts()
Strips off any unneeded pointer casts, all-zero GEPs and aliases from the specified value...
VariableDbgInfoMapTy VariableDbgInfo
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
MMIAddrLabelMapCallbackPtr(Value *V)
bool hasInitializer() const
MachineBasicBlock * LandingPadBlock
int getFilterIDFor(std::vector< unsigned > &TyIds)
unsigned getPersonalityIndex() const
Value * operator=(Value *RHS)
void addFilterTypeInfo(MachineBasicBlock *LandingPad, ArrayRef< const GlobalVariable * > TyInfo)
LLVM Value Representation.
virtual bool doInitialization(Module &)
void UpdateForDeletedBlock(BasicBlock *BB)
const MCRegisterInfo & MRI
void setPtr(BasicBlock *BB)
const Function * getPersonality() const
getPersonality - Return the personality function for the current function.