49 unsigned LSize = LIds.size(), RSize = RIds.size();
50 unsigned MinSize = LSize < RSize ? LSize : RSize;
53 for (; Count != MinSize; ++Count)
54 if (LIds[Count] != RIds[Count])
63 unsigned LSize = LIds.size(), RSize = RIds.size();
64 unsigned MinSize = LSize < RSize ? LSize : RSize;
66 for (
unsigned i = 0; i != MinSize; ++i)
67 if (LIds[i] != RIds[i])
68 return LIds[i] < RIds[i];
105 FilterOffsets.
reserve(FilterIds.size());
108 for (std::vector<unsigned>::const_iterator
109 I = FilterIds.begin(), E = FilterIds.end();
I != E; ++
I) {
117 unsigned SizeActions = 0;
121 I = LandingPads.
begin(), E = LandingPads.
end();
I != E; ++
I) {
123 const std::vector<int> &TypeIds = LPI->
TypeIds;
124 unsigned NumShared = PrevLPI ?
SharedTypeIds(LPI, PrevLPI) : 0;
125 unsigned SizeSiteActions = 0;
127 if (NumShared < TypeIds.size()) {
128 unsigned SizeAction = 0;
132 unsigned SizePrevIds = PrevLPI->
TypeIds.size();
133 assert(Actions.
size());
134 PrevAction = Actions.
size() - 1;
139 for (
unsigned j = NumShared; j != SizePrevIds; ++j) {
140 assert(PrevAction != (
unsigned)-1 &&
"PrevAction is invalid!");
143 SizeAction += -Actions[PrevAction].NextAction;
144 PrevAction = Actions[PrevAction].Previous;
149 for (
unsigned J = NumShared, M = TypeIds.size(); J != M; ++J) {
151 assert(-1 - TypeID < (
int)FilterOffsets.
size() &&
"Unknown filter id!");
152 int ValueForTypeID = TypeID < 0 ? FilterOffsets[-1 -
TypeID] :
TypeID;
155 int NextAction = SizeAction ? -(SizeAction + SizeTypeID) : 0;
157 SizeSiteActions += SizeAction;
159 ActionEntry Action = { ValueForTypeID, NextAction, PrevAction };
161 PrevAction = Actions.
size() - 1;
165 FirstAction = SizeActions + SizeSiteActions - SizeAction + 1;
176 SizeActions += SizeSiteActions;
187 assert(MI->
isCall() &&
"This should be a call instruction!");
189 bool MarkedNoUnwind =
false;
190 bool SawFunc =
false;
198 if (F == 0)
continue;
207 MarkedNoUnwind =
false;
215 return MarkedNoUnwind;
235 bool SawPotentiallyThrowing =
false;
238 bool PreviousIsInvoke =
false;
245 if (!
MI->isLabel()) {
252 MCSymbol *BeginLabel =
MI->getOperand(0).getMCSymbol();
253 if (BeginLabel == LastLabel)
254 SawPotentiallyThrowing =
false;
258 if (L == PadMap.
end())
265 "Inconsistent landing pad map!");
274 PreviousIsInvoke =
false;
278 assert(BeginLabel && LastLabel &&
"Invalid landing pad!");
282 PreviousIsInvoke =
false;
309 if (CallSites.
size() < SiteNo)
311 CallSites[SiteNo - 1] = Site;
313 PreviousIsInvoke =
true;
348 const std::vector<const GlobalVariable *> &TypeInfos =
MMI->
getTypeInfos();
355 LandingPads.
reserve(PadInfos.size());
357 for (
unsigned i = 0,
N = PadInfos.size(); i !=
N; ++i)
372 for (
unsigned i = 0,
N = LandingPads.
size(); i !=
N; ++i) {
374 for (
unsigned j = 0, E = LandingPad->
BeginLabels.size(); j != E; ++j) {
376 assert(!PadMap.
count(BeginLabel) &&
"Duplicate landing pad labels!");
378 PadMap[BeginLabel] =
P;
390 bool HaveTTData = IsSJLJ ? (!TypeInfos.empty() || !FilterIds.empty()) :
true;
392 unsigned CallSiteTableLength;
394 CallSiteTableLength = 0;
396 unsigned SiteStartSize = 4;
397 unsigned SiteLengthSize = 4;
398 unsigned LandingPadSize = 4;
399 CallSiteTableLength =
400 CallSites.
size() * (SiteStartSize + SiteLengthSize + LandingPadSize);
403 for (
unsigned i = 0, e = CallSites.
size(); i < e; ++i) {
411 unsigned TTypeEncoding;
412 unsigned TypeFormatSize;
490 unsigned SizeTypes = TypeInfos.size() * TypeFormatSize;
491 unsigned CallSiteTableLengthSize =
493 unsigned TTypeBaseOffset =
495 CallSiteTableLengthSize +
496 CallSiteTableLength +
503 (HaveTTData ? TTypeBaseOffsetSize : 0) +
505 unsigned SizeAlign = (4 - TotalSize) & 3;
510 Asm->
EmitULEB128(TTypeBaseOffset,
"@TType base offset", SizeAlign);
521 Asm->
EmitULEB128(CallSiteTableLength,
"Call site table length", SizeAlign);
526 I = CallSites.
begin(), E = CallSites.
end();
I != E; ++
I, ++idx) {
575 Asm->
EmitULEB128(CallSiteTableLength,
"Call site table length", SizeAlign);
579 I = CallSites.
begin(), E = CallSites.
end();
I != E; ++
I) {
587 BeginLabel = EHFuncBeginSym;
601 BeginLabel->
getName() +
" and " +
635 I = Actions.begin(), E = Actions.end();
I != E; ++
I) {
667 unsigned NextAction = Entry + (Action.
NextAction + 1) / 2;
680 const std::vector<const GlobalVariable *> &TypeInfos =
MMI->
getTypeInfos();
687 if (VerboseAsm && !TypeInfos.empty()) {
690 Entry = TypeInfos.size();
693 for (std::vector<const GlobalVariable *>::const_reverse_iterator
694 I = TypeInfos.rbegin(), E = TypeInfos.rend();
I != E; ++
I) {
702 if (VerboseAsm && !FilterIds.empty()) {
707 for (std::vector<unsigned>::const_iterator
708 I = FilterIds.begin(), E = FilterIds.end();
I < E; ++
I) {
bool isExceptionHandlingDwarf() const
void push_back(const T &Elt)
virtual void AddComment(const Twine &T)
const GlobalValue * getGlobal() const
MachineModuleInfo * MMI
MMI - Collected machine module information.
virtual void EndFunction()
EndFunction - Gather and emit post-function exception information.
const DataLayout & getDataLayout() const
getDataLayout - Return information about data layout.
virtual void AddBlankLine()
AddBlankLine - Emit a blank line to a .s file to pretty it up.
const std::vector< const GlobalVariable * > & getTypeInfos() const
unsigned getPointerSize(unsigned AS=0) const
enable_if_c<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
void EmitLabelDifference(const MCSymbol *Hi, const MCSymbol *Lo, unsigned Size) const
ActionEntry - Structure describing an entry in the actions table.
const MachineFunction * MF
The current machine function.
static unsigned SharedTypeIds(const LandingPadInfo *L, const LandingPadInfo *R)
SharedTypeIds - How many leading type ids two landing pads have in common.
unsigned getCallSiteBeginLabel(MCSymbol *BeginLabel)
getCallSiteBeginLabel - Get the call site number for a begin label.
ExceptionHandling::ExceptionsType getExceptionHandlingType() const
unsigned getFunctionNumber() const
MCSymbol * LandingPadLabel
MCSymbol * GetOrCreateSymbol(StringRef Name)
bool CallToNoUnwindFunction(const MachineInstr *MI)
bool doesNotThrow() const
Determine if the function cannot unwind.
SmallVector< MCSymbol *, 1 > BeginLabels
CallSiteEntry - Structure describing an entry in the call-site table.
static unsigned getSLEB128Size(int64_t Value)
const std::vector< unsigned > & getFilterIds() const
#define llvm_unreachable(msg)
virtual bool isVerboseAsm() const
unsigned getNumOperands() const
bool isGlobal() const
isGlobal - Tests if this is a MO_GlobalAddress operand.
unsigned getTTypeEncoding() const
void SwitchSection(const MCSection *Section, const MCExpr *Subsection=0)
AsmPrinter * Asm
Asm - Target of Dwarf emission.
virtual void EmitIntValue(uint64_t Value, unsigned Size)
void ComputeCallSiteTable(SmallVectorImpl< CallSiteEntry > &CallSites, const RangeMapType &PadMap, const SmallVectorImpl< const LandingPadInfo * > &LPs, const SmallVectorImpl< unsigned > &FirstActions)
virtual void BeginFunction(const MachineFunction *MF)
PadRange - Structure holding a try-range and the associated landing pad.
unsigned GetSizeOfEncodedValue(unsigned Encoding) const
GetSizeOfEncodedValue - Return the size of the encoding in bytes.
SmallVector< MCSymbol *, 1 > EndLabels
const MachineOperand & getOperand(unsigned i) const
std::vector< int > TypeIds
bool count(const KeyT &Val) const
count - Return true if the specified key is in the map.
void EmitSLEB128(int64_t Value, const char *Desc=0) const
EmitSLEB128 - emit the specified signed leb128 value.
virtual void EmitTypeInfos(unsigned TTypeEncoding)
virtual void EmitLabel(MCSymbol *Symbol)
virtual ~DwarfException()
void EmitTTypeReference(const GlobalValue *GV, unsigned Encoding) const
EmitReference - Emit reference to a ttype global with a specified encoding.
const MCSection * getLSDASection() const
unsigned ComputeActionsTable(const SmallVectorImpl< const LandingPadInfo * > &LPs, SmallVectorImpl< ActionEntry > &Actions, SmallVectorImpl< unsigned > &FirstActions)
bundle_iterator< const MachineInstr, const_instr_iterator > const_iterator
StringRef getName() const
getName - Get the symbol name.
void EmitULEB128(uint64_t Value, const char *Desc=0, unsigned PadTo=0) const
EmitULEB128 - emit the specified unsigned leb128 value.
void EmitEncodingByte(unsigned Val, const char *Desc=0) const
const std::vector< LandingPadInfo > & getLandingPads() const
bool isCall(QueryType Type=AnyInBundle) const
void EmitAlignment(unsigned NumBits, const GlobalValue *GV=0) const
static bool PadLT(const LandingPadInfo *L, const LandingPadInfo *R)
PadLT - Order landing pads lexicographically by type id.
void EmitExceptionTable()
const TargetLoweringObjectFile & getObjFileLowering() const
getObjFileLowering - Return information about object file lowering.
static unsigned getULEB128Size(uint64_t Value)
DwarfException(AsmPrinter *A)
MCSymbol * GetTempSymbol(StringRef Name, unsigned ID) const
iterator find(const KeyT &Val)