47 unsigned LSize = LIds.size(), RSize = RIds.size();
48 unsigned MinSize = LSize < RSize ? LSize : RSize;
51 for (; Count != MinSize; ++Count)
52 if (LIds[Count] != RIds[Count])
89 FilterOffsets.
reserve(FilterIds.size());
92 for (std::vector<unsigned>::const_iterator
93 I = FilterIds.begin(),
E = FilterIds.end();
I !=
E; ++
I) {
101 unsigned SizeActions = 0;
105 I = LandingPads.
begin(),
E = LandingPads.
end();
I !=
E; ++
I) {
107 const std::vector<int> &TypeIds = LPI->
TypeIds;
108 unsigned NumShared = PrevLPI ?
sharedTypeIDs(LPI, PrevLPI) : 0;
109 unsigned SizeSiteActions = 0;
111 if (NumShared < TypeIds.size()) {
113 unsigned SizeActionEntry = 0;
117 unsigned SizePrevIds = PrevLPI->
TypeIds.size();
119 PrevAction = Actions.
size() - 1;
120 SizeActionEntry =
getSLEB128Size(Actions[PrevAction].NextAction) +
123 for (
unsigned j = NumShared; j != SizePrevIds; ++j) {
124 assert(PrevAction != (
unsigned)-1 &&
"PrevAction is invalid!");
125 SizeActionEntry -=
getSLEB128Size(Actions[PrevAction].ValueForTypeID);
126 SizeActionEntry += -Actions[PrevAction].NextAction;
127 PrevAction = Actions[PrevAction].Previous;
132 for (
unsigned J = NumShared, M = TypeIds.size(); J != M; ++J) {
134 assert(-1 - TypeID < (
int)FilterOffsets.
size() &&
"Unknown filter id!");
139 int NextAction = SizeActionEntry ? -(SizeActionEntry + SizeTypeID) : 0;
141 SizeSiteActions += SizeActionEntry;
143 ActionEntry Action = { ValueForTypeID, NextAction, PrevAction };
145 PrevAction = Actions.
size() - 1;
149 FirstAction = SizeActions + SizeSiteActions - SizeActionEntry + 1;
160 SizeActions += SizeSiteActions;
169 assert(MI->
isCall() &&
"This should be a call instruction!");
171 bool MarkedNoUnwind =
false;
172 bool SawFunc =
false;
189 MarkedNoUnwind =
false;
197 return MarkedNoUnwind;
206 for (
unsigned i = 0,
N = LandingPads.
size(); i !=
N; ++i) {
208 for (
unsigned j = 0,
E = LandingPad->
BeginLabels.size(); j !=
E; ++j) {
210 assert(!PadMap.
count(BeginLabel) &&
"Duplicate landing pad labels!");
212 PadMap[BeginLabel] =
P;
235 bool SawPotentiallyThrowing =
false;
238 bool PreviousIsInvoke =
false;
243 for (
const auto &MBB : *
Asm->
MF) {
244 for (
const auto &
MI : MBB) {
245 if (!
MI.isEHLabel()) {
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;
293 if (PreviousIsInvoke && !IsSJLJ) {
309 if (CallSites.
size() < SiteNo)
311 CallSites[SiteNo - 1] = Site;
313 PreviousIsInvoke =
true;
321 if (SawPotentiallyThrowing && !IsSJLJ) {
351 const std::vector<const GlobalValue *> &TypeInfos = MF->
getTypeInfos();
352 const std::vector<unsigned> &FilterIds = MF->
getFilterIds();
353 const std::vector<LandingPadInfo> &PadInfos = MF->
getLandingPads();
358 LandingPads.
reserve(PadInfos.size());
360 for (
unsigned i = 0,
N = PadInfos.size(); i !=
N; ++i)
380 unsigned CallSiteEncoding =
383 bool HaveTTData = !TypeInfos.empty() || !FilterIds.empty();
387 unsigned TTypeEncoding;
464 if (IsSJLJ || IsWasm) {
467 I = CallSites.
begin(),
E = CallSites.
end();
I !=
E; ++
I, ++idx) {
519 BeginLabel = EHFuncBeginSym;
530 BeginLabel->
getName() +
" and " +
565 I = Actions.begin(),
E = Actions.end();
I !=
E; ++
I) {
597 unsigned NextAction = Entry + (Action.
NextAction + 1) / 2;
615 const std::vector<const GlobalValue *> &TypeInfos = MF->
getTypeInfos();
616 const std::vector<unsigned> &FilterIds = MF->
getFilterIds();
622 if (VerboseAsm && !TypeInfos.empty()) {
625 Entry = TypeInfos.size();
638 if (VerboseAsm && !FilterIds.empty()) {
643 for (std::vector<unsigned>::const_iterator
644 I = FilterIds.begin(),
E = FilterIds.end();
I <
E; ++
I) {
void EmitCallSiteOffset(const MCSymbol *Hi, const MCSymbol *Lo, unsigned Encoding) const
Emit reference to a call site with a specified encoding.
const TargetLoweringObjectFile & getObjFileLowering() const
Return information about object file lowering.
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.
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
Structure describing an entry in the call-site table.
bool isCall(QueryType Type=AnyInBundle) const
typename SuperClass::const_iterator const_iterator
std::unique_ptr< MCStreamer > OutStreamer
This is the MCStreamer object for the file we are generating.
This class represents lattice values for constants.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
MCContext & OutContext
This is the context for the output file that we are streaming.
void push_back(const T &Elt)
setjmp/longjmp based exceptions
EHStreamer(AsmPrinter *A)
unsigned getCallSiteEncoding() const
This provides a very simple, boring adaptor for a begin and end iterator into a range type...
static bool callToNoUnwindFunction(const MachineInstr *MI)
Return `true' if this is a call to a function marked `nounwind'.
unsigned getCallSiteBeginLabel(MCSymbol *BeginLabel) const
Get the call site number for a begin label.
void EmitAlignment(Align Alignment, const GlobalObject *GV=nullptr) const
Emit an alignment directive to the specified power of two boundary.
MachineFunction * MF
The current machine function.
MCSymbol * LandingPadLabel
Structure describing an entry in the actions table.
void reserve(size_type N)
static bool isFilterEHSelector(int Selector)
const LandingPadInfo * LPad
const std::vector< unsigned > & getFilterIds() const
Return a reference to the typeids encoding filters used in the current function.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
SmallVector< MCSymbol *, 1 > EndLabels
unsigned getNumOperands() const
Retuns the total number of operands.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void computeActionsTable(const SmallVectorImpl< const LandingPadInfo *> &LandingPads, SmallVectorImpl< ActionEntry > &Actions, SmallVectorImpl< unsigned > &FirstActions)
Compute the actions table and gather the first action index for each landing pad site.
TypeID
Definitions of all of the base types for the Type system.
unsigned getTTypeEncoding() const
This structure is used to retain landing pad info for the current function.
MCSymbol * getFunctionBegin() const
void EmitLabelDifferenceAsULEB128(const MCSymbol *Hi, const MCSymbol *Lo) const
Emit something like ".uleb128 Hi-Lo".
iterator find(const_arg_type_t< KeyT > Val)
WebAssembly Exception Handling.
const MCAsmInfo * MAI
Target Asm Printer information.
void EmitULEB128(uint64_t Value, const char *Desc=nullptr, unsigned PadTo=0) const
Emit the specified unsigned leb128 value.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
SmallVector< MCSymbol *, 1 > BeginLabels
const GlobalValue * getGlobal() const
void EmitEncodingByte(unsigned Val, const char *Desc=nullptr) const
Emit a .byte 42 directive that corresponds to an encoding.
This class is intended to be used as a driving class for all asm writers.
std::vector< int > TypeIds
void EmitCallSiteValue(uint64_t Value, unsigned Encoding) const
Emit an integer value corresponding to the call site encoding.
AsmPrinter * Asm
Target of directive emission.
unsigned getULEB128Size(uint64_t Value)
Utility function to get the size of the ULEB128-encoded value.
void sort(IteratorTy Start, IteratorTy End)
bool doesNotThrow() const
Determine if the function cannot unwind.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
unsigned getFunctionNumber() const
Return a unique ID for the current function.
const std::vector< LandingPadInfo > & getLandingPads() const
Return a reference to the landing pad info for the current function.
void EmitSLEB128(int64_t Value, const char *Desc=nullptr) const
Emit the specified signed leb128 value.
bool isGlobal() const
isGlobal - Tests if this is a MO_GlobalAddress operand.
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...
virtual void emitTypeInfos(unsigned TTypeEncoding, MCSymbol *TTBaseLabel)
void EmitTTypeReference(const GlobalValue *GV, unsigned Encoding) const
Emit reference to a ttype global with a specified encoding.
MCSymbol * getFunctionEnd() const
bool usesCFIForEH() const
Returns true if the exception handling method for the platform uses call frame information to unwind...
virtual void computeCallSiteTable(SmallVectorImpl< CallSiteEntry > &CallSites, const SmallVectorImpl< const LandingPadInfo *> &LandingPads, const SmallVectorImpl< unsigned > &FirstActions)
Compute the call-site table.
This file contains constants used for implementing Dwarf debug support.
MCSymbol * getCurExceptionSym()
void computePadMap(const SmallVectorImpl< const LandingPadInfo *> &LandingPads, RangeMapType &PadMap)
Representation of each machine instruction.
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
size_type count(const_arg_type_t< KeyT > Val) const
Return 1 if the specified key is in the map, 0 otherwise.
unsigned getSLEB128Size(int64_t Value)
Utility function to get the size of the SLEB128-encoded value.
StringRef getName() const
getName - Get the symbol name.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
MCSymbol * emitExceptionTable()
Emit landing pads and actions.
ExceptionHandling getExceptionHandlingType() const
MCSection * getLSDASection() const
const std::vector< const GlobalValue * > & getTypeInfos() const
Return a reference to the C++ typeinfo for the current function.
const MachineOperand & getOperand(unsigned i) const
Structure holding a try-range and the associated landing pad.
MCSymbol * createTempSymbol(const Twine &Name) const