LLVM 17.0.0git
llvm::EHStreamer Class Reference

Emits exception handling directives. More...

#include "CodeGen/AsmPrinter/EHStreamer.h"

Inheritance diagram for llvm::EHStreamer:
[legend]
Collaboration diagram for llvm::EHStreamer:
[legend]

## Classes

struct  ActionEntry
Structure describing an entry in the actions table. More...

struct  CallSiteEntry
Structure describing an entry in the call-site table. More...

struct  CallSiteRange
Structure describing a contiguous range of call-sites which reside in the same procedure fragment. More...

Structure holding a try-range and the associated landing pad. More...

## Public Member Functions

EHStreamer (AsmPrinter *A)

~EHStreamer () override

void setSymbolSize (const MCSymbol *Sym, uint64_t Size) override
For symbols that have a size designated (e.g.

void beginInstruction (const MachineInstr *MI) override
Process beginning of an instruction.

void endInstruction () override
Process end of an instruction.

Public Member Functions inherited from llvm::AsmPrinterHandler
virtual ~AsmPrinterHandler ()
Pin vtable to this file.

virtual void setSymbolSize (const MCSymbol *Sym, uint64_t Size)=0
For symbols that have a size designated (e.g.

virtual void beginModule (Module *M)

virtual void endModule ()=0
Emit all sections that should come after the content.

virtual void beginFunction (const MachineFunction *MF)=0
Gather pre-function debug information.

virtual void markFunctionEnd ()

virtual void endFunction (const MachineFunction *MF)=0
Gather post-function debug information.

virtual void beginBasicBlockSection (const MachineBasicBlock &MBB)
Process the beginning of a new basic-block-section within a function.

virtual void endBasicBlockSection (const MachineBasicBlock &MBB)
Process the end of a basic-block-section within a function.

virtual void beginFunclet (const MachineBasicBlock &MBB, MCSymbol *Sym=nullptr)
Emit target-specific EH funclet machinery.

virtual void endFunclet ()

virtual void beginInstruction (const MachineInstr *MI)=0
Process beginning of an instruction.

virtual void endInstruction ()=0
Process end of an instruction.

## Static Public Member Functions

static bool callToNoUnwindFunction (const MachineInstr *MI)
Return ‘true’ if this is a call to a function marked ‘nounwind’.

## Protected Types

using RangeMapType = DenseMap< MCSymbol *, PadRange >

## Protected Member Functions

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.

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.

MCSymbolemitExceptionTable ()

virtual void emitTypeInfos (unsigned TTypeEncoding, MCSymbol *TTBaseLabel)

## Static Protected Member Functions

static bool isFilterEHSelector (int Selector)

static bool isCleanupEHSelector (int Selector)

static bool isCatchEHSelector (int Selector)

## Protected Attributes

AsmPrinterAsm
Target of directive emission.

MachineModuleInfoMMI
Collected machine module information.

## Detailed Description

Emits exception handling directives.

Definition at line 30 of file EHStreamer.h.

## ◆ RangeMapType

 using llvm::EHStreamer::RangeMapType = DenseMap
protected

Definition at line 51 of file EHStreamer.h.

## ◆ EHStreamer()

 EHStreamer::EHStreamer ( AsmPrinter * A )

Definition at line 38 of file EHStreamer.cpp.

## ◆ ~EHStreamer()

 EHStreamer::~EHStreamer ( )
overridedefault

## ◆ beginInstruction()

 void llvm::EHStreamer::beginInstruction ( const MachineInstr * MI )
inlineoverridevirtual

Process beginning of an instruction.

Implements llvm::AsmPrinterHandler.

Definition at line 155 of file EHStreamer.h.

## ◆ callToNoUnwindFunction()

 bool EHStreamer::callToNoUnwindFunction ( const MachineInstr * MI )
static

Return ‘true’ if this is a call to a function marked ‘nounwind’.

Return ‘false’ otherwise.

Definition at line 158 of file EHStreamer.cpp.

References assert(), F, and MI.

Referenced by computeCallSiteTable().

## ◆ computeActionsTable()

 void EHStreamer::computeActionsTable ( const SmallVectorImpl< const LandingPadInfo * > & LandingPads, SmallVectorImpl< ActionEntry > & Actions, SmallVectorImpl< unsigned > & FirstActions )
protected

Compute the actions table and gather the first action index for each landing pad site.

Definition at line 53 of file EHStreamer.cpp.

Referenced by emitExceptionTable().

## ◆ computeCallSiteTable()

 void EHStreamer::computeCallSiteTable ( SmallVectorImpl< CallSiteEntry > & CallSites, SmallVectorImpl< CallSiteRange > & CallSiteRanges, const SmallVectorImpl< const LandingPadInfo * > & LandingPads, const SmallVectorImpl< unsigned > & FirstActions )
protectedvirtual

Compute the call-site table and the call-site ranges.

Compute the call-site table.

The entry for an invoke has a try-range containing the call, a non-zero landing pad and an appropriate action. The entry for an ordinary call has a try-range containing the call and zero for the landing pad and the action. Calls marked 'nounwind' have no entry and must not be contained in the try-range of any entry - they form gaps in the table. Entries must be ordered by try-range address. CallSiteRanges vector is only populated for Itanium exception handling.

The entry for an invoke has a try-range containing the call, a non-zero landing pad, and an appropriate action. The entry for an ordinary call has a try-range containing the call and zero for the landing pad and the action. Calls marked 'nounwind' have no entry and must not be contained in the try-range of any entry - they form gaps in the table. Entries must be ordered by try-range address.

Call-sites are split into one or more call-site ranges associated with different sections of the function.

• Without -basic-block-sections, all call-sites are grouped into one call-site-range corresponding to the function section.
• With -basic-block-sections, one call-site range is created for each section, with its FragmentBeginLabel and FragmentEndLabel respectively

Reimplemented in llvm::WasmException.

Definition at line 231 of file EHStreamer.cpp.

Referenced by emitExceptionTable().

protected

Definition at line 188 of file EHStreamer.cpp.

Referenced by computeCallSiteTable().

## ◆ emitExceptionTable()

 MCSymbol * EHStreamer::emitExceptionTable ( )
protected

The general organization of the table is complex, but the basic concepts are easy. First there is a header which describes the location and organization of the three components that follow.

1. The landing pad site information describes the range of code covered by the try. In our case it's an accumulation of the ranges covered by the invokes in the try. There is also a reference to the landing pad that handles the exception once processed. Finally an index into the actions table.
2. The action table, in our case, is composed of pairs of type ids and next action offset. Starting with the action index from the landing pad site, each type Id is checked for a match to the current exception. If it matches then the exception and type id are passed on to the landing pad. Otherwise the next action is looked up. This chain is terminated with a next action of zero. If no type id is found the frame is unwound and handling continues.
3. Type id table contains references to all the C++ typeinfo for all catches in the function. This tables is reversed indexed base 1.

Returns the starting symbol of an exception table.

The general organization of the table is complex, but the basic concepts are easy. First there is a header which describes the location and organization of the three components that follow.

1. The landing pad site information describes the range of code covered by the try. In our case it's an accumulation of the ranges covered by the invokes in the try. There is also a reference to the landing pad that handles the exception once processed. Finally an index into the actions table.
2. The action table, in our case, is composed of pairs of type IDs and next action offset. Starting with the action index from the landing pad site, each type ID is checked for a match to the current exception. If it matches then the exception and type id are passed on to the landing pad. Otherwise the next action is looked up. This chain is terminated with a next action of zero. If no type id is found then the frame is unwound and handling continues.
3. Type ID table contains references to all the C++ typeinfo for all catches in the function. This tables is reverse indexed base 1.

Returns the starting symbol of an exception table.

Definition at line 381 of file EHStreamer.cpp.

## ◆ emitTypeInfos()

 void EHStreamer::emitTypeInfos ( unsigned TTypeEncoding, MCSymbol * TTBaseLabel )
protectedvirtual

Definition at line 810 of file EHStreamer.cpp.

Referenced by emitExceptionTable().

## ◆ endInstruction()

 void llvm::EHStreamer::endInstruction ( )
inlineoverridevirtual

Process end of an instruction.

Implements llvm::AsmPrinterHandler.

Definition at line 156 of file EHStreamer.h.

## ◆ isCatchEHSelector()

 static bool llvm::EHStreamer::isCatchEHSelector ( int Selector )
inlinestaticprotected

Definition at line 147 of file EHStreamer.h.

## ◆ isCleanupEHSelector()

 static bool llvm::EHStreamer::isCleanupEHSelector ( int Selector )
inlinestaticprotected

Definition at line 146 of file EHStreamer.h.

## ◆ isFilterEHSelector()

 static bool llvm::EHStreamer::isFilterEHSelector ( int Selector )
inlinestaticprotected

Definition at line 145 of file EHStreamer.h.

Referenced by computeActionsTable(), and emitTypeInfos().

## ◆ setSymbolSize()

 void llvm::EHStreamer::setSymbolSize ( const MCSymbol * Sym, uint64_t Size )
inlineoverridevirtual

For symbols that have a size designated (e.g.

common symbols), this tracks that size.

Implements llvm::AsmPrinterHandler.

Definition at line 154 of file EHStreamer.h.

## ◆ sharedTypeIDs()

 unsigned EHStreamer::sharedTypeIDs ( const LandingPadInfo * L, const LandingPadInfo * R )
staticprotected

Definition at line 43 of file EHStreamer.cpp.

Referenced by computeActionsTable().

## ◆ MMI

 MachineModuleInfo* llvm::EHStreamer::MMI
protected

Collected machine module information.

Definition at line 36 of file EHStreamer.h.

The documentation for this class was generated from the following files: