Go to the documentation of this file.
45 const std::vector<int> &LIds = L->
TypeIds, &RIds = R->TypeIds;
46 return std::mismatch(LIds.begin(), LIds.end(), RIds.begin(), RIds.end())
82 FilterOffsets.
reserve(FilterIds.size());
85 for (
unsigned FilterId : FilterIds) {
86 FilterOffsets.push_back(Offset);
90 FirstActions.
reserve(LandingPads.size());
93 unsigned SizeActions = 0;
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()) {
103 unsigned SizeActionEntry = 0;
104 unsigned PrevAction = (unsigned)-1;
107 unsigned SizePrevIds = PrevLPI->
TypeIds.size();
109 PrevAction = Actions.size() - 1;
110 SizeActionEntry =
getSLEB128Size(Actions[PrevAction].NextAction) +
113 for (
unsigned j = NumShared;
j != SizePrevIds; ++
j) {
114 assert(PrevAction != (
unsigned)-1 &&
"PrevAction is invalid!");
115 SizeActionEntry -=
getSLEB128Size(Actions[PrevAction].ValueForTypeID);
116 SizeActionEntry += -Actions[PrevAction].NextAction;
117 PrevAction = Actions[PrevAction].Previous;
122 for (
unsigned J = NumShared,
M = TypeIds.size(); J !=
M; ++J) {
124 assert(-1 -
TypeID < (
int)FilterOffsets.size() &&
"Unknown filter id!");
129 int NextAction = SizeActionEntry ? -(SizeActionEntry + SizeTypeID) : 0;
131 SizeSiteActions += SizeActionEntry;
133 ActionEntry Action = { ValueForTypeID, NextAction, PrevAction };
134 Actions.push_back(Action);
135 PrevAction = Actions.size() - 1;
139 FirstAction = SizeActions + SizeSiteActions - SizeActionEntry + 1;
147 FirstActions.push_back(FirstAction);
150 SizeActions += SizeSiteActions;
159 assert(
MI->isCall() &&
"This should be a call instruction!");
161 bool MarkedNoUnwind =
false;
162 bool SawFunc =
false;
165 if (!MO.isGlobal())
continue;
167 const Function *
F = dyn_cast<Function>(MO.getGlobal());
177 MarkedNoUnwind =
false;
181 MarkedNoUnwind =
F->doesNotThrow();
185 return MarkedNoUnwind;
194 for (
unsigned i = 0,
N = LandingPads.size();
i !=
N; ++
i) {
198 assert(!PadMap.
count(BeginLabel) &&
"Duplicate landing pad labels!");
200 PadMap[BeginLabel] =
P;
238 bool SawPotentiallyThrowing =
false;
241 bool PreviousIsInvoke =
false;
250 CallSiteRanges.push_back(
254 PreviousIsInvoke =
false;
255 SawPotentiallyThrowing =
false;
260 CallSiteRanges.back().IsLPRange =
true;
262 for (
const auto &
MI :
MBB) {
263 if (!
MI.isEHLabel()) {
270 MCSymbol *BeginLabel =
MI.getOperand(0).getMCSymbol();
271 if (BeginLabel == LastLabel)
272 SawPotentiallyThrowing =
false;
276 if (L == PadMap.
end())
283 "Inconsistent landing pad map!");
289 if (SawPotentiallyThrowing &&
292 CallSites.push_back({LastLabel, BeginLabel,
nullptr, 0});
293 PreviousIsInvoke =
false;
296 LastLabel = LandingPad->
EndLabels[
P.RangeIndex];
297 assert(BeginLabel && LastLabel &&
"Invalid landing pad!");
301 PreviousIsInvoke =
false;
308 FirstActions[
P.PadIndex]
312 if (PreviousIsInvoke && !IsSJLJ) {
323 CallSites.push_back(Site);
328 if (CallSites.size() < SiteNo)
330 CallSites[SiteNo - 1] = Site;
332 PreviousIsInvoke =
true;
342 if (SawPotentiallyThrowing && !IsSJLJ) {
343 CallSiteEntry Site = {LastLabel, CallSiteRanges.back().FragmentEndLabel,
345 CallSites.push_back(Site);
346 SawPotentiallyThrowing =
false;
348 CallSiteRanges.back().CallSiteEndIdx = CallSites.size();
377 const std::vector<const GlobalValue *> &TypeInfos = MF->
getTypeInfos();
378 const std::vector<unsigned> &FilterIds = MF->
getFilterIds();
379 const std::vector<LandingPadInfo> &PadInfos = MF->
getLandingPads();
384 LandingPads.
reserve(PadInfos.size());
387 LandingPads.push_back(&LPI);
391 return L->
TypeIds < R->TypeIds;
411 unsigned CallSiteEncoding =
414 bool HaveTTData = !TypeInfos.empty() || !FilterIds.empty();
419 unsigned TTypeEncoding;
469 CallSiteRanges.size() > 1 ?
"action_table_base" :
"cst_end");
481 auto EmitTypeTableRefAndCallSiteTableEndRef = [&]() {
509 auto EmitTypeTableOffsetAndCallSiteTableOffset = [&]() {
511 "Targets supporting .uleb128 do not need to take this path.");
512 if (CallSiteRanges.size() > 1)
514 "-fbasic-block-sections is not yet supported on "
515 "platforms that do not have general LEB128 directive support.");
530 const unsigned ByteSizeOfCallSiteOffset =
540 const unsigned TypeInfoSize =
543 const uint64_t LSDASizeBeforeAlign =
545 + ByteSizeOfCallSiteOffset
549 const uint64_t LSDASizeWithoutAlign = LSDASizeBeforeAlign + TypeInfoSize;
550 const unsigned ByteSizeOfLSDAWithoutAlign =
552 const uint64_t DisplacementBeforeAlign =
554 + ByteSizeOfLSDAWithoutAlign + LSDASizeBeforeAlign;
557 const unsigned NeedAlignVal = (4 - DisplacementBeforeAlign % 4) % 4;
558 uint64_t LSDASizeWithAlign = LSDASizeWithoutAlign + NeedAlignVal;
559 const unsigned ByteSizeOfLSDAWithAlign =
565 if (ByteSizeOfLSDAWithAlign > ByteSizeOfLSDAWithoutAlign)
566 LSDASizeWithAlign -= 1;
569 ByteSizeOfLSDAWithAlign);
577 if (IsSJLJ || IsWasm) {
582 EmitTypeTableRefAndCallSiteTableEndRef();
586 I = CallSites.begin(),
E = CallSites.end();
I !=
E; ++
I, ++idx) {
604 Twine((
S.Action - 1) / 2 + 1));
630 assert(CallSiteRanges.size() != 0 &&
"No call-site ranges!");
636 if (CSRange.IsLPRange) {
637 assert(LandingPadRange ==
nullptr &&
638 "All landing pads must be in a single callsite range.");
639 LandingPadRange = &CSRange;
658 if (CSRange.CallSiteBeginIdx != 0) {
668 if (CallSiteRanges.size() == 1) {
691 if (HasLEB128Directives)
692 EmitTypeTableRefAndCallSiteTableEndRef();
694 EmitTypeTableOffsetAndCallSiteTableOffset();
696 for (
size_t CallSiteIdx = CSRange.CallSiteBeginIdx;
697 CallSiteIdx != CSRange.CallSiteEndIdx; ++CallSiteIdx) {
700 MCSymbol *EHFuncBeginSym = CSRange.FragmentBeginLabel;
701 MCSymbol *EHFuncEndSym = CSRange.FragmentEndLabel;
705 BeginLabel = EHFuncBeginSym;
708 EndLabel = EHFuncEndSym;
717 BeginLabel->
getName() +
" and " +
730 S.LPad->LandingPadLabel->getName());
744 Twine((
S.Action - 1) / 2 + 1));
765 if (Action.ValueForTypeID > 0)
767 Twine(Action.ValueForTypeID));
768 else if (Action.ValueForTypeID < 0)
770 Twine(Action.ValueForTypeID));
778 if (Action.Previous ==
unsigned(-1)) {
782 Twine(Action.Previous + 1));
799 const std::vector<const GlobalValue *> &TypeInfos = MF->
getTypeInfos();
800 const std::vector<unsigned> &FilterIds = MF->
getFilterIds();
806 if (VerboseAsm && !TypeInfos.empty()) {
809 Entry = TypeInfos.size();
821 if (VerboseAsm && !FilterIds.empty()) {
826 for (std::vector<unsigned>::const_iterator
827 I = FilterIds.begin(),
E = FilterIds.end();
I <
E; ++
I) {
bool isPositionIndependent() const
void emitLabelDifferenceAsULEB128(const MCSymbol *Hi, const MCSymbol *Lo) const
Emit something like ".uleb128 Hi-Lo".
This is an optimization pass for GlobalISel generic memory operations.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
virtual void computeCallSiteTable(SmallVectorImpl< CallSiteEntry > &CallSites, SmallVectorImpl< CallSiteRange > &CallSiteRanges, const SmallVectorImpl< const LandingPadInfo * > &LandingPads, const SmallVectorImpl< unsigned > &FirstActions)
Compute the call-site table and the call-site ranges.
void emitULEB128(uint64_t Value, const char *Desc=nullptr, unsigned PadTo=0) const
Emit the specified unsigned leb128 value.
@ SjLj
setjmp/longjmp based exceptions
MCSymbol * createTempSymbol(const Twine &Name) const
Context object for machine code objects.
This currently compiles esp xmm0 movsd esp eax eax esp ret We should use not the dag combiner This is because dagcombine2 needs to be able to see through the X86ISD::Wrapper which DAGCombine can t really do The code for turning x load into a single vector load is target independent and should be moved to the dag combiner The code for turning x load into a vector load can only handle a direct load from a global or a direct load from the stack It should be generalized to handle any load from P
const MCAsmInfo * MAI
Target Asm Printer information.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
MCSymbol * LandingPadLabel
void emitSLEB128(int64_t Value, const char *Desc=nullptr) const
Emit the specified signed leb128 value.
bool hasLEB128Directives() const
const MachineBasicBlock & back() const
unsigned getULEB128Size(uint64_t Value)
Utility function to get the size of the ULEB128-encoded value.
void emitAlignment(Align Alignment, const GlobalObject *GV=nullptr, unsigned MaxBytesToEmit=0) const
Emit an alignment directive to the specified power of two boundary.
auto reverse(ContainerTy &&C, std::enable_if_t< has_rbegin< ContainerTy >::value > *=nullptr)
unsigned getCodePointerSize() const
Get the code pointer size in bytes.
size_type count(const_arg_type_t< KeyT > Val) const
Return 1 if the specified key is in the map, 0 otherwise.
bool usesCFIForEH() const
Returns true if the exception handling method for the platform uses call frame information to unwind.
void emitCallSiteOffset(const MCSymbol *Hi, const MCSymbol *Lo, unsigned Encoding) const
Emit reference to a call site with a specified encoding.
const LandingPadInfo * LPad
virtual void emitTypeInfos(unsigned TTypeEncoding, MCSymbol *TTBaseLabel)
@ AIX
AIX Exception Handling.
bool isBeginSection() const
Returns true if this block begins any section.
const MachineBasicBlock & front() const
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
unsigned getTTypeEncoding() const
SmallVector< MCSymbol *, 1 > EndLabels
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
const std::vector< unsigned > & getFilterIds() const
Return a reference to the typeids encoding filters used in the current function.
std::unique_ptr< MCStreamer > OutStreamer
This is the MCStreamer object for the file we are generating.
MCSymbol * emitExceptionTable()
Emit landing pads and actions.
std::vector< int > TypeIds
MachineOperand class - Representation of each machine instruction operand.
MCSymbol * CurrentFnSym
The symbol for the current function.
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
@ Wasm
WebAssembly Exception Handling.
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.
StringRef getName() const
getName - Get the symbol name.
static bool isFilterEHSelector(int Selector)
MCSymbol * getFunctionBegin() const
virtual MCSection * getSectionForLSDA(const Function &, const MCSymbol &, const TargetMachine &) const
unsigned getSectionIDNum() const
Returns the unique section ID number of this basic block.
unsigned getCallSiteEncoding() const
static unsigned sharedTypeIDs(const LandingPadInfo *L, const LandingPadInfo *R)
How many leading type ids two landing pads have in common.
EHStreamer(AsmPrinter *A)
SmallVector< MCSymbol *, 1 > BeginLabels
Representation of each machine instruction.
unsigned GetSizeOfEncodedValue(unsigned Encoding) const
Return the size of the encoding in bytes.
Structure describing a contiguous range of call-sites which reside in the same procedure fragment.
constexpr bool isUInt< 32 >(uint64_t x)
iterator find(const_arg_type_t< KeyT > Val)
typename SuperClass::const_iterator const_iterator
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static const MCBinaryExpr * createSub(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
MCSymbol * getMBBExceptionSym(const MachineBasicBlock &MBB)
MachineFunction * MF
The current machine function.
const std::vector< LandingPadInfo > & getLandingPads() const
Return a reference to the landing pad info for the current function.
static bool callToNoUnwindFunction(const MachineInstr *MI)
Return ‘true’ if this is a call to a function marked ‘nounwind’.
MCContext & OutContext
This is the context for the output file that we are streaming.
Structure describing an entry in the actions table.
Structure describing an entry in the call-site table.
AsmPrinter * Asm
Target of directive emission.
bool isEHPad() const
Returns true if the block is a landing pad.
Instances of this class represent a uniqued identifier for a section in the current translation unit.
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
unsigned getSLEB128Size(int64_t Value)
Utility function to get the size of the SLEB128-encoded value.
void computePadMap(const SmallVectorImpl< const LandingPadInfo * > &LandingPads, RangeMapType &PadMap)
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Function & getFunction()
Return the LLVM function that this machine code represents.
bool isEndSection() const
Returns true if this block ends any section.
void sort(IteratorTy Start, IteratorTy End)
This class is intended to be used as a driving class for all asm writers.
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
ExceptionHandling getExceptionHandlingType() const
virtual void emitTTypeReference(const GlobalValue *GV, unsigned Encoding)
Emit reference to a ttype global with a specified encoding.
MapVector< unsigned, MBBSectionRange > MBBSectionRanges
TargetMachine & TM
Target machine description.
const TargetLoweringObjectFile & getObjFileLowering() const
Return information about object file lowering.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
unsigned getCallSiteBeginLabel(MCSymbol *BeginLabel) const
Get the call site number for a begin label.
This structure is used to retain landing pad info for the current function.
const std::vector< const GlobalValue * > & getTypeInfos() const
Return a reference to the C++ typeinfo for the current function.
void emitCallSiteValue(uint64_t Value, unsigned Encoding) const
Emit an integer value corresponding to the call site encoding.
TypeID
Definitions of all of the base types for the Type system.
Structure holding a try-range and the associated landing pad.
void reserve(size_type N)
unsigned getFunctionNumber() const
Return a unique ID for the current function.
void emitEncodingByte(unsigned Val, const char *Desc=nullptr) const
Emit a .byte 42 directive that corresponds to an encoding.
MCSymbol * FragmentBeginLabel