LLVM  8.0.1
Classes | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
llvm::EHStreamer Class Reference

Emits exception handling directives. More...

#include "CodeGen/AsmPrinter/EHStreamer.h"

Inheritance diagram for llvm::EHStreamer:
Inheritance graph
[legend]
Collaboration diagram for llvm::EHStreamer:
Collaboration graph
[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  PadRange
 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. More...
 
void beginInstruction (const MachineInstr *MI) override
 Process beginning of an instruction. More...
 
void endInstruction () override
 Process end of an instruction. More...
 
- Public Member Functions inherited from llvm::AsmPrinterHandler
virtual ~AsmPrinterHandler ()
 Pin vtable to this file. More...
 
virtual void endModule ()=0
 Emit all sections that should come after the content. More...
 
virtual void beginFunction (const MachineFunction *MF)=0
 Gather pre-function debug information. More...
 
virtual void markFunctionEnd ()
 
virtual void endFunction (const MachineFunction *MF)=0
 Gather post-function debug information. More...
 
virtual void beginFragment (const MachineBasicBlock *MBB, ExceptionSymbolProvider ESP)
 
virtual void endFragment ()
 
virtual void beginFunclet (const MachineBasicBlock &MBB, MCSymbol *Sym=nullptr)
 Emit target-specific EH funclet machinery. More...
 
virtual void endFunclet ()
 

Static Public Member Functions

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

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. More...
 
void computePadMap (const SmallVectorImpl< const LandingPadInfo *> &LandingPads, RangeMapType &PadMap)
 
virtual void computeCallSiteTable (SmallVectorImpl< CallSiteEntry > &CallSites, const SmallVectorImpl< const LandingPadInfo *> &LandingPads, const SmallVectorImpl< unsigned > &FirstActions)
 Compute the call-site table. More...
 
MCSymbolemitExceptionTable ()
 Emit landing pads and actions. More...
 
virtual void emitTypeInfos (unsigned TTypeEncoding, MCSymbol *TTBaseLabel)
 

Static Protected Member Functions

static unsigned sharedTypeIDs (const LandingPadInfo *L, const LandingPadInfo *R)
 How many leading type ids two landing pads have in common. More...
 
static bool isFilterEHSelector (int Selector)
 
static bool isCleanupEHSelector (int Selector)
 
static bool isCatchEHSelector (int Selector)
 

Protected Attributes

AsmPrinterAsm
 Target of directive emission. More...
 
MachineModuleInfoMMI
 Collected machine module information. More...
 

Detailed Description

Emits exception handling directives.

Definition at line 31 of file EHStreamer.h.

Member Typedef Documentation

◆ RangeMapType

Definition at line 52 of file EHStreamer.h.

Constructor & Destructor Documentation

◆ EHStreamer()

EHStreamer::EHStreamer ( AsmPrinter A)

Definition at line 40 of file EHStreamer.cpp.

References ~EHStreamer().

◆ ~EHStreamer()

EHStreamer::~EHStreamer ( )
overridedefault

Referenced by EHStreamer().

Member Function Documentation

◆ beginInstruction()

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

Process beginning of an instruction.

Implements llvm::AsmPrinterHandler.

Definition at line 131 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 169 of file EHStreamer.cpp.

References assert(), llvm::Function::doesNotThrow(), llvm::dyn_cast(), E, F(), llvm::MachineOperand::getGlobal(), llvm::MachineInstr::getNumOperands(), llvm::MachineInstr::getOperand(), I, llvm::MachineInstr::isCall(), and llvm::MachineOperand::isGlobal().

Referenced by computeCallSiteTable().

◆ computeActionsTable()

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

◆ computeCallSiteTable()

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

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.

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.

Reimplemented in llvm::WasmException.

Definition at line 225 of file EHStreamer.cpp.

References llvm::EHStreamer::CallSiteEntry::Action, Asm, assert(), llvm::SmallVectorTemplateCommon< T >::back(), llvm::LandingPadInfo::BeginLabels, callToNoUnwindFunction(), computePadMap(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::end(), llvm::EHStreamer::CallSiteEntry::EndLabel, llvm::LandingPadInfo::EndLabels, llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::find(), llvm::MachineFunction::getCallSiteBeginLabel(), llvm::MCAsmInfo::getExceptionHandlingType(), llvm::LandingPadInfo::LandingPadLabel, llvm::EHStreamer::CallSiteEntry::LPad, llvm::AsmPrinter::MAI, llvm::AsmPrinter::MF, MI, P, llvm::EHStreamer::PadRange::PadIndex, llvm::SmallVectorTemplateBase< T >::push_back(), llvm::EHStreamer::PadRange::RangeIndex, llvm::SmallVectorImpl< T >::resize(), llvm::SmallVectorBase::size(), llvm::SjLj, and llvm::MCAsmInfo::usesCFIForEH().

Referenced by computePadMap(), and emitExceptionTable().

◆ computePadMap()

void EHStreamer::computePadMap ( const SmallVectorImpl< const LandingPadInfo *> &  LandingPads,
RangeMapType PadMap 
)
protected

◆ emitExceptionTable()

MCSymbol * EHStreamer::emitExceptionTable ( )
protected

Emit landing pads and actions.

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 350 of file EHStreamer.cpp.

References llvm::EHStreamer::CallSiteEntry::Action, Asm, llvm::SmallVectorTemplateCommon< T >::begin(), llvm::EHStreamer::CallSiteEntry::BeginLabel, computeActionsTable(), computeCallSiteTable(), llvm::AsmPrinter::createTempSymbol(), llvm::dwarf::DW_EH_PE_omit, llvm::dwarf::DW_EH_PE_udata4, llvm::dwarf::DW_EH_PE_uleb128, E, llvm::AsmPrinter::EmitAlignment(), llvm::AsmPrinter::EmitEncodingByte(), llvm::AsmPrinter::EmitLabelDifferenceAsULEB128(), llvm::AsmPrinter::EmitSLEB128(), emitTypeInfos(), llvm::AsmPrinter::EmitULEB128(), llvm::SmallVectorTemplateCommon< T >::end(), llvm::EHStreamer::CallSiteEntry::EndLabel, llvm::AsmPrinter::getCurExceptionSym(), llvm::MCAsmInfo::getExceptionHandlingType(), llvm::MachineFunction::getFilterIds(), llvm::AsmPrinter::getFunctionBegin(), llvm::AsmPrinter::getFunctionEnd(), llvm::AsmPrinter::getFunctionNumber(), llvm::MachineFunction::getLandingPads(), llvm::MCObjectFileInfo::getLSDASection(), llvm::MCSymbol::getName(), llvm::AsmPrinter::getObjFileLowering(), llvm::MCContext::getOrCreateSymbol(), llvm::TargetLoweringObjectFile::getTTypeEncoding(), llvm::MachineFunction::getTypeInfos(), I, llvm::LandingPadInfo::LandingPadLabel, llvm::EHStreamer::CallSiteEntry::LPad, llvm::AsmPrinter::MAI, llvm::AsmPrinter::MF, N, llvm::EHStreamer::ActionEntry::NextAction, llvm::AsmPrinter::OutContext, llvm::AsmPrinter::OutStreamer, llvm::SmallVectorTemplateBase< T >::push_back(), llvm::SmallVectorImpl< T >::reserve(), llvm::SjLj, llvm::sort(), llvm::LandingPadInfo::TypeIds, llvm::EHStreamer::ActionEntry::ValueForTypeID, and llvm::Wasm.

Referenced by llvm::WasmException::endFunction(), llvm::DwarfCFIException::endFunction(), llvm::ARMException::endFunction(), and llvm::WinException::endFunction().

◆ emitTypeInfos()

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

◆ endInstruction()

void llvm::EHStreamer::endInstruction ( )
inlineoverridevirtual

Process end of an instruction.

Implements llvm::AsmPrinterHandler.

Definition at line 132 of file EHStreamer.h.

References MI.

◆ isCatchEHSelector()

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

Definition at line 123 of file EHStreamer.h.

◆ isCleanupEHSelector()

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

Definition at line 122 of file EHStreamer.h.

◆ isFilterEHSelector()

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

Definition at line 121 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 130 of file EHStreamer.h.

◆ sharedTypeIDs()

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

How many leading type ids two landing pads have in common.

Definition at line 45 of file EHStreamer.cpp.

References llvm::LandingPadInfo::TypeIds.

Referenced by computeActionsTable().

Member Data Documentation

◆ Asm

AsmPrinter* llvm::EHStreamer::Asm
protected

◆ MMI

MachineModuleInfo* llvm::EHStreamer::MMI
protected

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