36 unsigned LSize = LIds.size(), RSize = RIds.size();
37 unsigned MinSize = LSize < RSize ? LSize : RSize;
40 for (; Count != MinSize; ++Count)
41 if (LIds[Count] != RIds[Count])
79 FilterOffsets.
reserve(FilterIds.size());
82 for (std::vector<unsigned>::const_iterator
83 I = FilterIds.begin(), E = FilterIds.end();
I != E; ++
I) {
91 unsigned SizeActions = 0;
95 I = LandingPads.
begin(), E = LandingPads.
end();
I != E; ++
I) {
97 const std::vector<int> &TypeIds = LPI->
TypeIds;
98 unsigned NumShared = PrevLPI ?
sharedTypeIDs(LPI, PrevLPI) : 0;
99 unsigned SizeSiteActions = 0;
101 if (NumShared < TypeIds.size()) {
102 unsigned SizeAction = 0;
106 unsigned SizePrevIds = PrevLPI->
TypeIds.size();
107 assert(Actions.
size());
108 PrevAction = Actions.
size() - 1;
112 for (
unsigned j = NumShared; j != SizePrevIds; ++j) {
113 assert(PrevAction != (
unsigned)-1 &&
"PrevAction is invalid!");
115 SizeAction += -Actions[PrevAction].NextAction;
116 PrevAction = Actions[PrevAction].Previous;
121 for (
unsigned J = NumShared, M = TypeIds.size(); J != M; ++J) {
123 assert(-1 - TypeID < (
int)FilterOffsets.
size() &&
"Unknown filter id!");
128 int NextAction = SizeAction ? -(SizeAction + SizeTypeID) : 0;
130 SizeSiteActions += SizeAction;
132 ActionEntry Action = { ValueForTypeID, NextAction, PrevAction };
134 PrevAction = Actions.
size() - 1;
138 FirstAction = SizeActions + SizeSiteActions - SizeAction + 1;
149 SizeActions += SizeSiteActions;
160 assert(MI->
isCall() &&
"This should be a call instruction!");
162 bool MarkedNoUnwind =
false;
163 bool SawFunc =
false;
180 MarkedNoUnwind =
false;
188 return MarkedNoUnwind;
197 for (
unsigned i = 0,
N = LandingPads.
size(); i !=
N; ++i) {
199 for (
unsigned j = 0, E = LandingPad->
BeginLabels.size(); j != E; ++j) {
201 assert(!PadMap.
count(BeginLabel) &&
"Duplicate landing pad labels!");
203 PadMap[BeginLabel] =
P;
226 bool SawPotentiallyThrowing =
false;
229 bool PreviousIsInvoke =
false;
234 for (
const auto &MBB : *
Asm->
MF) {
235 for (
const auto &
MI : MBB) {
236 if (!
MI.isEHLabel()) {
243 MCSymbol *BeginLabel =
MI.getOperand(0).getMCSymbol();
244 if (BeginLabel == LastLabel)
245 SawPotentiallyThrowing =
false;
249 if (L == PadMap.
end())
256 "Inconsistent landing pad map!");
265 PreviousIsInvoke =
false;
269 assert(BeginLabel && LastLabel &&
"Invalid landing pad!");
273 PreviousIsInvoke =
false;
284 if (PreviousIsInvoke && !IsSJLJ) {
300 if (CallSites.
size() < SiteNo)
302 CallSites[SiteNo - 1] = Site;
304 PreviousIsInvoke =
true;
312 if (SawPotentiallyThrowing && !IsSJLJ && LastLabel !=
nullptr) {
339 const std::vector<const GlobalValue *> &TypeInfos =
MMI->
getTypeInfos();
346 LandingPads.
reserve(PadInfos.size());
348 for (
unsigned i = 0,
N = PadInfos.size(); i !=
N; ++i)
352 std::sort(LandingPads.
begin(), LandingPads.
end(),
360 unsigned SizeActions =
371 bool HaveTTData = IsSJLJ ? (!TypeInfos.empty() || !FilterIds.empty()) :
true;
373 unsigned CallSiteTableLength;
375 CallSiteTableLength = 0;
377 unsigned SiteStartSize = 4;
378 unsigned SiteLengthSize = 4;
379 unsigned LandingPadSize = 4;
380 CallSiteTableLength =
381 CallSites.
size() * (SiteStartSize + SiteLengthSize + LandingPadSize);
384 for (
unsigned i = 0, e = CallSites.
size(); i < e; ++i) {
392 unsigned TTypeEncoding;
393 unsigned TypeFormatSize;
466 unsigned SizeTypes = TypeInfos.size() * TypeFormatSize;
467 unsigned CallSiteTableLengthSize =
getULEB128Size(CallSiteTableLength);
468 unsigned TTypeBaseOffset =
470 CallSiteTableLengthSize +
471 CallSiteTableLength +
478 (HaveTTData ? TTypeBaseOffsetSize : 0) +
480 unsigned SizeAlign = (4 - TotalSize) & 3;
485 Asm->
EmitULEB128(TTypeBaseOffset,
"@TType base offset", SizeAlign);
496 Asm->
EmitULEB128(CallSiteTableLength,
"Call site table length", SizeAlign);
501 I = CallSites.
begin(), E = CallSites.
end();
I != E; ++
I, ++idx) {
549 Asm->
EmitULEB128(CallSiteTableLength,
"Call site table length", SizeAlign);
553 I = CallSites.
begin(), E = CallSites.
end();
I != E; ++
I) {
560 BeginLabel = EHFuncBeginSym;
573 BeginLabel->
getName() +
" and " +
607 I = Actions.begin(), E = Actions.end();
I != E; ++
I) {
639 unsigned NextAction = Entry + (Action.
NextAction + 1) / 2;
652 const std::vector<const GlobalValue *> &TypeInfos =
MMI->
getTypeInfos();
659 if (VerboseAsm && !TypeInfos.empty()) {
662 Entry = TypeInfos.size();
665 for (std::vector<const GlobalValue *>::const_reverse_iterator
666 I = TypeInfos.rbegin(), E = TypeInfos.rend();
I != E; ++
I) {
674 if (VerboseAsm && !FilterIds.empty()) {
679 for (std::vector<unsigned>::const_iterator
680 I = FilterIds.begin(), E = FilterIds.end();
I < E; ++
I) {
Instances of this class represent a uniqued identifier for a section in the current translation unit...
static unsigned sharedTypeIDs(const LandingPadInfo *L, const LandingPadInfo *R)
How many leading type ids two landing pads have in common.
void push_back(const T &Elt)
Structure describing an entry in the call-site table.
const GlobalValue * getGlobal() const
std::unique_ptr< MCStreamer > OutStreamer
This is the MCStreamer object for the file we are generating.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
const DataLayout & getDataLayout() const
Return information about data layout.
MCContext & OutContext
This is the context for the output file that we are streaming.
DWARF-like instruction based exceptions.
EHStreamer(AsmPrinter *A)
void EmitLabelDifference(const MCSymbol *Hi, const MCSymbol *Lo, unsigned Size) const
Emit something like ".long Hi-Lo" where the size in bytes of the directive is specified by Size and H...
bool callToNoUnwindFunction(const MachineInstr *MI)
Return `true' if this is a call to a function marked `nounwind'.
const MachineFunction * MF
The current machine function.
unsigned getCallSiteBeginLabel(MCSymbol *BeginLabel)
getCallSiteBeginLabel - Get the call site number for a begin label.
unsigned getFunctionNumber() const
Return a unique ID for the current function.
MCSymbol * LandingPadLabel
Structure describing an entry in the actions table.
void reserve(size_type N)
static bool isFilterEHSelector(int Selector)
const LandingPadInfo * LPad
MachineModuleInfo * MMI
Collected machine module information.
bool doesNotThrow() const
Determine if the function cannot unwind.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
SmallVector< MCSymbol *, 1 > EndLabels
const std::vector< unsigned > & getFilterIds() const
getFilterIds - Return a reference to the typeids encoding filters used in the current function...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
TypeID
Definitions of all of the base types for the Type system.
void EmitEncodingByte(unsigned Val, const char *Desc=nullptr) const
Emit a .byte 42 directive that corresponds to an encoding.
unsigned getNumOperands() const
Access to explicit operands of the instruction.
bool isGlobal() const
isGlobal - Tests if this is a MO_GlobalAddress operand.
unsigned getTTypeEncoding() const
void emitExceptionTable()
Emit landing pads and actions.
LandingPadInfo - This structure is used to retain landing pad info for the current function...
const std::vector< const GlobalValue * > & getTypeInfos() const
getTypeInfos - Return a reference to the C++ typeinfo for the current function.
void computeCallSiteTable(SmallVectorImpl< CallSiteEntry > &CallSites, const SmallVectorImpl< const LandingPadInfo * > &LPs, const SmallVectorImpl< unsigned > &FirstActions)
Compute the call-site table.
MCSection * getLSDASection() const
const MCAsmInfo * MAI
Target Asm Printer information.
unsigned GetSizeOfEncodedValue(unsigned Encoding) const
Return the size of the encoding in bytes.
SmallVector< MCSymbol *, 1 > BeginLabels
void EmitULEB128(uint64_t Value, const char *Desc=nullptr, unsigned PadTo=0) const
Emit the specified unsigned leb128 value.
const MachineOperand & getOperand(unsigned i) const
This class is intended to be used as a driving class for all asm writers.
std::vector< int > TypeIds
ExceptionHandling getExceptionHandlingType() const
unsigned computeActionsTable(const SmallVectorImpl< const LandingPadInfo * > &LPs, SmallVectorImpl< ActionEntry > &Actions, SmallVectorImpl< unsigned > &FirstActions)
Compute the actions table and gather the first action index for each landing pad site.
virtual void emitTypeInfos(unsigned TTypeEncoding)
AsmPrinter * Asm
Target of directive emission.
unsigned getULEB128Size(uint64_t Value)
Utility function to get the size of the ULEB128-encoded value.
void EmitAlignment(unsigned NumBits, const GlobalObject *GO=nullptr) const
Emit an alignment directive to the specified power of two boundary.
MachineOperand class - Representation of each machine instruction operand.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
void EmitTTypeReference(const GlobalValue *GV, unsigned Encoding) const
Emit reference to a ttype global with a specified encoding.
size_type count(const KeyT &Val) const
Return 1 if the specified key is in the map, 0 otherwise.
MCSymbol * getCurExceptionSym()
LLVM_ATTRIBUTE_UNUSED_RESULT std::enable_if< !is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
Representation of each machine instruction.
StringRef getName() const
getName - Get the symbol name.
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
const std::vector< LandingPadInfo > & getLandingPads() const
getLandingPads - Return a reference to the landing pad info for the current function.
MCSymbol * getFunctionBegin() const
void computePadMap(const SmallVectorImpl< const LandingPadInfo * > &LandingPads, RangeMapType &PadMap)
void EmitSLEB128(int64_t Value, const char *Desc=nullptr) const
Emit the specified signed leb128 value.
bool isCall(QueryType Type=AnyInBundle) const
iterator find(const KeyT &Val)
MCSymbol * getFunctionEnd() const
unsigned getSLEB128Size(int64_t Value)
Utility function to get the size of the SLEB128-encoded value.
const TargetLoweringObjectFile & getObjFileLowering() const
Return information about object file lowering.
bool usesCFIForEH() const
Returns true if the exception handling method for the platform uses call frame information to unwind...
unsigned getPointerSize(unsigned AS=0) const
Layout pointer size FIXME: The defaults need to be removed once all of the backends/clients are updat...
Structure holding a try-range and the associated landing pad.