LLVM API Documentation

Classes | Public Member Functions | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes
llvm::EHStreamer Class Reference

Emits exception handling directives. More...

#include <EHStreamer.h>

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

List of all members.

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)
virtual ~EHStreamer ()
void endModule () override
 Emit all exception information that should come after the content.
void beginFunction (const MachineFunction *MF) override
void endFunction (const MachineFunction *) override
 Gather and emit post-function exception information.
void setSymbolSize (const MCSymbol *Sym, uint64_t Size) override
 For symbols that have a size designated (e.g. common symbols), this tracks that size.
void beginInstruction (const MachineInstr *MI) override
 Process beginning of an instruction.
void endInstruction () override
 Process end of an instruction.

Protected Types

typedef DenseMap< MCSymbol
*, PadRange
RangeMapType

Protected Member Functions

unsigned computeActionsTable (const SmallVectorImpl< const LandingPadInfo * > &LPs, SmallVectorImpl< ActionEntry > &Actions, SmallVectorImpl< unsigned > &FirstActions)
bool callToNoUnwindFunction (const MachineInstr *MI)
void computeCallSiteTable (SmallVectorImpl< CallSiteEntry > &CallSites, const RangeMapType &PadMap, const SmallVectorImpl< const LandingPadInfo * > &LPs, const SmallVectorImpl< unsigned > &FirstActions)
void emitExceptionTable ()
virtual void emitTypeInfos (unsigned TTypeEncoding)

Static Protected Member Functions

static unsigned sharedTypeIDs (const LandingPadInfo *L, const LandingPadInfo *R)
 How many leading type ids two landing pads have in common.

Protected Attributes

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

Detailed Description

Emits exception handling directives.

Definition at line 31 of file EHStreamer.h.


Member Typedef Documentation

Definition at line 51 of file EHStreamer.h.


Constructor & Destructor Documentation

Definition at line 28 of file EHStreamer.cpp.

EHStreamer::~EHStreamer ( ) [virtual]

Definition at line 30 of file EHStreamer.cpp.


Member Function Documentation

void EHStreamer::beginFunction ( const MachineFunction MF) [override, virtual]

Gather pre-function exception information. Assumes being emitted immediately after the function entry point.

Gather pre-function exception information. Assumes it's being emitted immediately after the function entry point.

Implements llvm::AsmPrinterHandler.

Reimplemented in llvm::ARMException, llvm::DwarfCFIException, and llvm::Win64Exception.

Definition at line 699 of file EHStreamer.cpp.

References llvm_unreachable.

void llvm::EHStreamer::beginInstruction ( const MachineInstr MI) [inline, override, virtual]

Process beginning of an instruction.

Implements llvm::AsmPrinterHandler.

Definition at line 132 of file EHStreamer.h.

Return `true' if this is a call to a function marked `nounwind'. Return `false' otherwise.

Definition at line 158 of file EHStreamer.cpp.

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

Referenced by computeCallSiteTable().

unsigned EHStreamer::computeActionsTable ( const SmallVectorImpl< const LandingPadInfo * > &  LandingPads,
SmallVectorImpl< ActionEntry > &  Actions,
SmallVectorImpl< unsigned > &  FirstActions 
) [protected]
void EHStreamer::computeCallSiteTable ( SmallVectorImpl< CallSiteEntry > &  CallSites,
const RangeMapType PadMap,
const SmallVectorImpl< const LandingPadInfo * > &  LandingPads,
const SmallVectorImpl< unsigned > &  FirstActions 
) [protected]

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.

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.

Definition at line 197 of file EHStreamer.cpp.

References llvm::EHStreamer::CallSiteEntry::Action, Asm, llvm::SmallVectorTemplateCommon< T >::back(), llvm::LandingPadInfo::BeginLabels, callToNoUnwindFunction(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT >::end(), llvm::EHStreamer::CallSiteEntry::EndLabel, llvm::LandingPadInfo::EndLabels, llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT >::find(), llvm::MachineModuleInfo::getCallSiteBeginLabel(), llvm::MCAsmInfo::isExceptionHandlingDwarf(), llvm::LandingPad, llvm::LandingPadInfo::LandingPadLabel, llvm::AsmPrinter::MAI, llvm::AsmPrinter::MF, llvm::AArch64CC::MI, MMI, P, llvm::EHStreamer::PadRange::PadIndex, llvm::EHStreamer::CallSiteEntry::PadLabel, llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), llvm::EHStreamer::PadRange::RangeIndex, llvm::SmallVectorImpl< T >::resize(), and llvm::SmallVectorTemplateCommon< T >::size().

Referenced by emitExceptionTable().

void 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.

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 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.

Definition at line 316 of file EHStreamer.cpp.

References llvm::EHStreamer::CallSiteEntry::Action, llvm::MCStreamer::AddComment(), Asm, llvm::SmallVectorTemplateCommon< T >::begin(), llvm::EHStreamer::CallSiteEntry::BeginLabel, llvm::LandingPadInfo::BeginLabels, computeActionsTable(), computeCallSiteTable(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT >::count(), llvm::dwarf::DW_EH_PE_omit, llvm::dwarf::DW_EH_PE_udata4, llvm::AsmPrinter::EmitAlignment(), llvm::AsmPrinter::EmitEncodingByte(), llvm::MCStreamer::EmitIntValue(), llvm::MCStreamer::EmitLabel(), llvm::AsmPrinter::EmitLabelDifference(), llvm::AsmPrinter::EmitSLEB128(), emitTypeInfos(), llvm::AsmPrinter::EmitULEB128(), llvm::SmallVectorTemplateCommon< T >::end(), llvm::EHStreamer::CallSiteEntry::EndLabel, llvm::AsmPrinter::getDataLayout(), llvm::MCAsmInfo::getExceptionHandlingType(), llvm::MachineModuleInfo::getFilterIds(), llvm::AsmPrinter::getFunctionNumber(), llvm::MachineModuleInfo::getLandingPads(), llvm::MCObjectFileInfo::getLSDASection(), llvm::MCSymbol::getName(), llvm::AsmPrinter::getObjFileLowering(), llvm::MCContext::GetOrCreateSymbol(), llvm::DataLayout::getPointerSize(), llvm::AsmPrinter::GetSizeOfEncodedValue(), llvm::AsmPrinter::GetTempSymbol(), llvm::MCObjectFileInfo::getTTypeEncoding(), llvm::MachineModuleInfo::getTypeInfos(), llvm::getULEB128Size(), I, llvm::MCAsmInfo::isExceptionHandlingDwarf(), llvm::MCStreamer::isVerboseAsm(), llvm::LandingPad, llvm::AsmPrinter::MAI, MMI, N, llvm::EHStreamer::ActionEntry::NextAction, llvm::AsmPrinter::OutContext, llvm::AsmPrinter::OutStreamer, P, llvm::EHStreamer::CallSiteEntry::PadLabel, llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), llvm::SmallVectorImpl< T >::reserve(), llvm::SmallVectorTemplateCommon< T >::size(), llvm::SmallVectorTemplateCommon< T, typename >::size(), llvm::SjLj, llvm::MCStreamer::SwitchSection(), llvm::LandingPadInfo::TypeIds, and llvm::EHStreamer::ActionEntry::ValueForTypeID.

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

void EHStreamer::emitTypeInfos ( unsigned  TTypeEncoding) [protected, virtual]
void EHStreamer::endFunction ( const MachineFunction ) [override, virtual]

Gather and emit post-function exception information.

Implements llvm::AsmPrinterHandler.

Reimplemented in llvm::ARMException, llvm::DwarfCFIException, and llvm::Win64Exception.

Definition at line 704 of file EHStreamer.cpp.

References llvm_unreachable.

void llvm::EHStreamer::endInstruction ( ) [inline, override, virtual]

Process end of an instruction.

Implements llvm::AsmPrinterHandler.

Definition at line 133 of file EHStreamer.h.

void EHStreamer::endModule ( ) [override, virtual]

Emit all exception information that should come after the content.

Implements llvm::AsmPrinterHandler.

Reimplemented in llvm::ARMException, llvm::DwarfCFIException, and llvm::Win64Exception.

Definition at line 693 of file EHStreamer.cpp.

References llvm_unreachable.

void llvm::EHStreamer::setSymbolSize ( const MCSymbol Sym,
uint64_t  Size 
) [inline, override, virtual]

For symbols that have a size designated (e.g. common symbols), this tracks that size.

Implements llvm::AsmPrinterHandler.

Definition at line 131 of file EHStreamer.h.

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

Definition at line 33 of file EHStreamer.cpp.

References llvm::LandingPadInfo::TypeIds.

Referenced by computeActionsTable().


Member Data Documentation


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