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();
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;
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) {
340 const std::vector<const GlobalValue *> &TypeInfos = MF->
getTypeInfos();
341 const std::vector<unsigned> &FilterIds = MF->
getFilterIds();
342 const std::vector<LandingPadInfo> &PadInfos = MF->
getLandingPads();
347 LandingPads.
reserve(PadInfos.size());
349 for (
unsigned i = 0,
N = PadInfos.size();
i !=
N; ++
i)
353 std::sort(LandingPads.
begin(), LandingPads.
end(),
361 unsigned SizeActions =
372 bool HaveTTData = IsSJLJ ? (!TypeInfos.empty() || !FilterIds.empty()) :
true;
374 unsigned CallSiteTableLength;
376 CallSiteTableLength = 0;
378 unsigned SiteStartSize = 4;
379 unsigned SiteLengthSize = 4;
380 unsigned LandingPadSize = 4;
381 CallSiteTableLength =
382 CallSites.
size() * (SiteStartSize + SiteLengthSize + LandingPadSize);
385 for (
unsigned i = 0, e = CallSites.
size(); i < e; ++
i) {
393 unsigned TTypeEncoding;
394 unsigned TypeFormatSize;
467 unsigned SizeTypes = TypeInfos.size() * TypeFormatSize;
468 unsigned CallSiteTableLengthSize =
getULEB128Size(CallSiteTableLength);
469 unsigned TTypeBaseOffset =
471 CallSiteTableLengthSize +
472 CallSiteTableLength +
479 (HaveTTData ? TTypeBaseOffsetSize : 0) +
481 unsigned SizeAlign = (4 - TotalSize) & 3;
486 Asm->
EmitULEB128(TTypeBaseOffset,
"@TType base offset", SizeAlign);
497 Asm->
EmitULEB128(CallSiteTableLength,
"Call site table length", SizeAlign);
502 I = CallSites.
begin(),
E = CallSites.
end();
I !=
E; ++
I, ++idx) {
550 Asm->
EmitULEB128(CallSiteTableLength,
"Call site table length", SizeAlign);
561 BeginLabel = EHFuncBeginSym;
574 BeginLabel->
getName() +
" and " +
608 I = Actions.begin(),
E = Actions.end();
I !=
E; ++
I) {
640 unsigned NextAction = Entry + (Action.
NextAction + 1) / 2;
654 const std::vector<const GlobalValue *> &TypeInfos = MF->
getTypeInfos();
655 const std::vector<unsigned> &FilterIds = MF->
getFilterIds();
661 if (VerboseAsm && !TypeInfos.empty()) {
664 Entry = TypeInfos.size();
675 if (VerboseAsm && !FilterIds.empty()) {
680 for (std::vector<unsigned>::const_iterator
681 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...
static bool callToNoUnwindFunction(const MachineInstr *MI)
Return `true' if this is a call to a function marked `nounwind'.
const MachineFunction * MF
The current machine function.
const std::vector< LandingPadInfo > & getLandingPads() const
Return a reference to the landing pad info for the current function.
const std::vector< unsigned > & getFilterIds() const
Return a reference to the typeids encoding filters used in the current function.
unsigned getFunctionNumber() const
Return a unique ID for the current function.
MCSymbol * LandingPadLabel
Structure describing an entry in the actions table.
const std::vector< const GlobalValue * > & getTypeInfos() const
Return a reference to the C++ typeinfo for the current function.
void reserve(size_type N)
static bool isFilterEHSelector(int Selector)
const LandingPadInfo * LPad
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
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.
This structure is used to retain landing pad info for the current function.
void computeCallSiteTable(SmallVectorImpl< CallSiteEntry > &CallSites, const SmallVectorImpl< const LandingPadInfo * > &LPs, const SmallVectorImpl< unsigned > &FirstActions)
Compute the call-site table.
static GCRegistry::Add< CoreCLRGC > E("coreclr","CoreCLR-compatible GC")
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
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator begin()
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.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
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()
Representation of each machine instruction.
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator end()
StringRef getName() const
getName - Get the symbol name.
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
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
LLVM_ATTRIBUTE_ALWAYS_INLINE size_type size() const
iterator find(const KeyT &Val)
MCSymbol * getFunctionEnd() const
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
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.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool usesCFIForEH() const
Returns true if the exception handling method for the platform uses call frame information to unwind...
unsigned getCallSiteBeginLabel(MCSymbol *BeginLabel) const
Get the call site number for a begin label.
unsigned getPointerSize(unsigned AS=0) const
Layout pointer size FIXME: The defaults need to be removed once all of the backends/clients are updat...
static GCRegistry::Add< ErlangGC > A("erlang","erlang-compatible garbage collector")
Structure holding a try-range and the associated landing pad.