GCC Middle and Back End API Reference
except.cc File Reference
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "backend.h"
#include "target.h"
#include "rtl.h"
#include "tree.h"
#include "cfghooks.h"
#include "tree-pass.h"
#include "memmodel.h"
#include "tm_p.h"
#include "stringpool.h"
#include "expmed.h"
#include "optabs.h"
#include "emit-rtl.h"
#include "cgraph.h"
#include "diagnostic.h"
#include "fold-const.h"
#include "stor-layout.h"
#include "explow.h"
#include "stmt.h"
#include "expr.h"
#include "calls.h"
#include "libfuncs.h"
#include "except.h"
#include "output.h"
#include "dwarf2asm.h"
#include "dwarf2.h"
#include "common/common-target.h"
#include "langhooks.h"
#include "cfgrtl.h"
#include "tree-pretty-print.h"
#include "cfgloop.h"
#include "builtins.h"
#include "tree-hash-traits.h"
#include "flags.h"
#include "gt-except.h"
Include dependency graph for except.cc:

Data Structures

struct  call_site_record_d
 
struct  action_record
 
struct  action_record_hasher
 
struct  duplicate_eh_regions_data
 
struct  ttypes_filter
 
struct  ttypes_filter_hasher
 
struct  ehspec_hasher
 

Typedefs

typedef hash_table< action_record_hasheraction_hash_type
 
typedef hash_table< ttypes_filter_hasherttypes_hash_type
 
typedef hash_table< ehspec_hasherehspec_hash_type
 

Functions

static bool get_eh_region_and_lp_from_rtx (const_rtx, eh_region *, eh_landing_pad *)
 
static void dw2_build_landing_pads (void)
 
static int collect_one_action_chain (action_hash_type *, eh_region)
 
static int add_call_site (rtx, int, int)
 
static void push_uleb128 (vec< uchar, va_gc > **, unsigned int)
 
static void push_sleb128 (vec< uchar, va_gc > **, int)
 
static int dw2_size_of_call_site_table (int)
 
static int sjlj_size_of_call_site_table (void)
 
static void dw2_output_call_site_table (int, int)
 
static void sjlj_output_call_site_table (void)
 
void init_eh (void)
 
void init_eh_for_function (void)
 
static eh_region gen_eh_region (enum eh_region_type type, eh_region outer)
 
eh_region gen_eh_region_cleanup (eh_region outer)
 
eh_region gen_eh_region_try (eh_region outer)
 
eh_catch gen_eh_region_catch (eh_region t, tree type_or_list)
 
eh_region gen_eh_region_allowed (eh_region outer, tree allowed)
 
eh_region gen_eh_region_must_not_throw (eh_region outer)
 
eh_landing_pad gen_eh_landing_pad (eh_region region)
 
eh_region get_eh_region_from_number_fn (struct function *ifun, int i)
 
eh_region get_eh_region_from_number (int i)
 
eh_landing_pad get_eh_landing_pad_from_number_fn (struct function *ifun, int i)
 
eh_landing_pad get_eh_landing_pad_from_number (int i)
 
eh_region get_eh_region_from_lp_number_fn (struct function *ifun, int i)
 
eh_region get_eh_region_from_lp_number (int i)
 
bool current_function_has_exception_handlers (void)
 
static void duplicate_eh_regions_1 (struct duplicate_eh_regions_data *data, eh_region old_r, eh_region outer)
 
hash_map< void *, void * > * duplicate_eh_regions (struct function *ifun, eh_region copy_region, int outer_lp, duplicate_eh_regions_map map, void *map_data)
 
eh_region eh_region_outermost (struct function *ifun, eh_region region_a, eh_region region_b)
 
void add_type_for_runtime (tree type)
 
tree lookup_type_for_runtime (tree type)
 
static int add_ttypes_entry (ttypes_hash_type *ttypes_hash, tree type)
 
static int add_ehspec_entry (ehspec_hash_type *ehspec_hash, ttypes_hash_type *ttypes_hash, tree list)
 
void assign_filter_values (void)
 
static basic_block emit_to_new_bb_before (rtx_insn *seq, rtx_insn *insn)
 
static void expand_dw2_landing_pad_for_region (eh_region region)
 
static int sjlj_assign_call_site_values (void)
 
static void sjlj_mark_call_sites (void)
 
static void sjlj_emit_function_enter (rtx_code_label *dispatch_label)
 
void sjlj_emit_function_exit_after (rtx_insn *after)
 
static void sjlj_emit_function_exit (void)
 
static void sjlj_emit_dispatch_table (rtx_code_label *dispatch_label, int num_dispatch)
 
static void sjlj_build_landing_pads (void)
 
void update_sjlj_context (void)
 
void finish_eh_generation (void)
 
void remove_eh_landing_pad (eh_landing_pad lp)
 
static void remove_eh_handler_splicer (eh_region *pp)
 
void remove_eh_handler (eh_region region)
 
static void remove_unreachable_eh_regions_worker (eh_region *pp, sbitmap r_reachable)
 
void remove_unreachable_eh_regions (sbitmap r_reachable)
 
void for_each_eh_label (void(*callback)(rtx))
 
void make_reg_eh_region_note (rtx_insn *insn, int ecf_flags, int lp_nr)
 
void make_reg_eh_region_note_nothrow_nononlocal (rtx_insn *insn)
 
bool insn_could_throw_p (const_rtx insn)
 
void copy_reg_eh_region_note_forward (rtx note_or_insn, rtx_insn *first, rtx last)
 
void copy_reg_eh_region_note_backward (rtx note_or_insn, rtx_insn *last, rtx first)
 
eh_landing_pad get_eh_landing_pad_from_rtx (const_rtx insn)
 
eh_region get_eh_region_from_rtx (const_rtx insn)
 
bool can_throw_internal (const_rtx insn)
 
bool can_throw_external (const_rtx insn)
 
bool insn_nothrow_p (const_rtx insn)
 
bool can_nonlocal_goto (const rtx_insn *insn)
 
static unsigned int set_nothrow_function_flags (void)
 
rtl_opt_passmake_pass_set_nothrow_function_flags (gcc::context *ctxt)
 
static eh_region expand_builtin_eh_common (tree region_nr_t)
 
rtx expand_builtin_eh_pointer (tree exp)
 
rtx expand_builtin_eh_filter (tree exp)
 
rtx expand_builtin_eh_copy_values (tree exp)
 
void expand_builtin_unwind_init (void)
 
rtx expand_builtin_eh_return_data_regno (tree exp)
 
rtx expand_builtin_extract_return_addr (tree addr_tree)
 
rtx expand_builtin_frob_return_addr (tree addr_tree)
 
void expand_builtin_eh_return (tree stackadj_tree, tree handler_tree)
 
void expand_eh_return (void)
 
rtx expand_builtin_extend_pointer (tree addr_tree)
 
static int add_action_record (action_hash_type *ar_hash, int filter, int next)
 
static rtx_noteemit_note_eh_region_end (rtx_insn *insn)
 
static bool maybe_add_nop_after_section_switch (void)
 
static unsigned int convert_to_eh_region_ranges (void)
 
rtl_opt_passmake_pass_convert_to_eh_region_ranges (gcc::context *ctxt)
 
static void switch_to_exception_section (const char *ARG_UNUSED(fnname))
 
static void output_ttype (tree type, int tt_format, int tt_format_size)
 
static void output_one_function_exception_table (int section)
 
void output_function_exception_table (int section)
 
void set_eh_throw_stmt_table (function *fun, hash_map< gimple *, int > *table)
 
hash_map< gimple *, int > * get_eh_throw_stmt_table (struct function *fun)
 
enum eh_personality_kind function_needs_eh_personality (struct function *fn)
 
void dump_eh_tree (FILE *out, struct function *fun)
 
DEBUG_FUNCTION void debug_eh_tree (struct function *fn)
 
DEBUG_FUNCTION void verify_eh_tree (struct function *fun)
 

Variables

static int call_site_base
 
static hash_map< tree_hash, tree > * type_to_runtime_map
 
static tree setjmp_fn
 
static tree sjlj_fc_type_node
 
static int sjlj_fc_call_site_ofs
 
static int sjlj_fc_data_ofs
 
static int sjlj_fc_personality_ofs
 
static int sjlj_fc_lsda_ofs
 
static int sjlj_fc_jbuf_ofs
 
static vec< int > sjlj_lp_call_site_index
 

Typedef Documentation

◆ action_hash_type

◆ ehspec_hash_type

◆ ttypes_hash_type

Function Documentation

◆ add_action_record()

static int add_action_record ( action_hash_type * ar_hash,
int filter,
int next )
static

◆ add_call_site()

static int add_call_site ( rtx landing_pad,
int action,
int section )
static

◆ add_ehspec_entry()

static int add_ehspec_entry ( ehspec_hash_type * ehspec_hash,
ttypes_hash_type * ttypes_hash,
tree list )
static
Add LIST to cfun->eh->ehspec_data, using EHSPEC_HASH and TYPES_HASH
to speed up the search.  Return the filter value to be used.   

References add_ttypes_entry(), cfun, ttypes_filter::filter, ggc_alloc(), NULL, NULL_TREE, push_uleb128(), ttypes_filter::t, targetm, TREE_CHAIN, TREE_VALUE, vec_safe_length(), and vec_safe_push().

Referenced by assign_filter_values().

◆ add_ttypes_entry()

static int add_ttypes_entry ( ttypes_hash_type * ttypes_hash,
tree type )
static
Add TYPE (which may be NULL) to cfun->eh->ttype_data, using TYPES_HASH
to speed up the search.  Return the filter value to be used.   

References cfun, ttypes_filter::filter, ggc_alloc(), NULL, ttypes_filter::t, TREE_HASH, type(), vec_safe_length(), and vec_safe_push().

Referenced by add_ehspec_entry(), and assign_filter_values().

◆ add_type_for_runtime()

◆ assign_filter_values()

void assign_filter_values ( void )
Generate the action filter values to be used for CATCH and
ALLOWED_EXCEPTIONS regions.  When using dwarf2 exception regions,
we use lots of landing pads, and so every type or list can share
the same filter value, which saves table space.   

References add_ehspec_entry(), add_ttypes_entry(), build_int_cst(), cfun, ERT_ALLOWED_EXCEPTIONS, ERT_TRY, eh_catch_d::filter_list, ggc_alloc(), i, integer_type_node, eh_catch_d::next_catch, NULL, NULL_TREE, r, targetm, TREE_CHAIN, tree_cons(), TREE_VALUE, eh_catch_d::type_list, vec_alloc(), and vec_safe_iterate().

◆ can_nonlocal_goto()

bool can_nonlocal_goto ( const rtx_insn * insn)
Return true if INSN can perform a non-local goto.   
??? This test is here in this file because it (ab)uses REG_EH_REGION.   

References CALL_P, find_reg_note(), ggc_alloc(), INT_MIN, INTVAL, nonlocal_goto_handler_labels, NULL_RTX, and XEXP.

Referenced by control_flow_insn_p(), create_trace_edges(), distribute_notes(), make_edges(), peep2_attempt(), and purge_dead_edges().

◆ can_throw_external()

◆ can_throw_internal()

◆ collect_one_action_chain()

◆ convert_to_eh_region_ranges()

static unsigned int convert_to_eh_region_ranges ( void )
static
Turn REG_EH_REGION notes back into NOTE_INSN_EH_REGION notes.
The new note numbers will not refer to region numbers, but
instead to call site entries.   

References add_call_site(), call_site_base, collect_one_action_chain(), crtl, emit_note_before(), emit_note_eh_region_end(), gcc_assert, GET_CODE, get_eh_region_and_lp_from_rtx(), get_insns(), ggc_alloc(), INSN_P, eh_landing_pad_d::landing_pad, NEXT_INSN(), NONJUMP_INSN_P, NOTE_EH_HANDLER, NOTE_KIND, NOTE_P, NULL, NULL_RTX, PATTERN(), pc_rtx, vec_alloc(), and XVECEXP.

◆ copy_reg_eh_region_note_backward()

void copy_reg_eh_region_note_backward ( rtx note_or_insn,
rtx_insn * last,
rtx first )
Likewise, but iterate backward.   

References add_reg_note(), find_reg_note(), ggc_alloc(), insn_could_throw_p(), INSN_P, last, NULL, NULL_RTX, PREV_INSN(), and XEXP.

Referenced by peep2_attempt(), and try_split().

◆ copy_reg_eh_region_note_forward()

void copy_reg_eh_region_note_forward ( rtx note_or_insn,
rtx_insn * first,
rtx last )
Copy an REG_EH_REGION note to each insn that might throw beginning
at FIRST and ending at LAST.  NOTE_OR_INSN is either the source insn
to look for a note, or the note itself.   

References add_reg_note(), find_reg_note(), ggc_alloc(), insn_could_throw_p(), INSN_P, last, NEXT_INSN(), NULL, NULL_RTX, and XEXP.

Referenced by emit_input_reload_insns(), emit_output_reload_insns(), fixup_eh_region_note(), lra_process_new_insns(), and resolve_simple_move().

◆ current_function_has_exception_handlers()

bool current_function_has_exception_handlers ( void )
Returns true if the current function has exception handling regions.   

References cfun, and NULL.

Referenced by suitable_for_tail_call_opt_p().

◆ debug_eh_tree()

DEBUG_FUNCTION void debug_eh_tree ( struct function * fn)
Dump the EH tree for FN on stderr.   

References dump_eh_tree(), and ggc_alloc().

◆ dump_eh_tree()

◆ duplicate_eh_regions()

hash_map< void *, void * > * duplicate_eh_regions ( struct function * ifun,
eh_region copy_region,
int outer_lp,
duplicate_eh_regions_map map,
void * map_data )
Duplicate the EH regions from IFUN rooted at COPY_REGION into
the current function and root the tree below OUTER_REGION.
The special case of COPY_REGION of NULL means all regions.
Remap labels using MAP/MAP_DATA callback.  Return a pointer map
that allows the caller to remap uses of both EH regions and
EH landing pads.   

References cfun, duplicate_eh_regions_1(), get_eh_region_from_lp_number_fn(), ggc_alloc(), map, r, and verify_eh_tree().

Referenced by copy_cfg_body(), and move_sese_region_to_fn().

◆ duplicate_eh_regions_1()

◆ dw2_build_landing_pads()

◆ dw2_output_call_site_table()

◆ dw2_size_of_call_site_table()

static int dw2_size_of_call_site_table ( int section)
static

◆ eh_region_outermost()

eh_region eh_region_outermost ( struct function * ifun,
eh_region region_a,
eh_region region_b )
Return the region that is outer to both REGION_A and REGION_B in IFUN.   

References bitmap_bit_p, bitmap_clear(), bitmap_set_bit, gcc_assert, and ggc_alloc().

Referenced by find_outermost_region_in_block().

◆ emit_note_eh_region_end()

static rtx_note * emit_note_eh_region_end ( rtx_insn * insn)
static

◆ emit_to_new_bb_before()

static basic_block emit_to_new_bb_before ( rtx_insn * seq,
rtx_insn * insn )
static
Emit SEQ into basic block just before INSN (that is assumed to be
first instruction of some existing BB and return the newly
produced block.   

References BARRIER_P, BLOCK_FOR_INSN(), create_basic_block(), ei_next(), ei_safe_edge(), ei_start, emit_insn_before(), emit_insn_before_setloc(), basic_block_def::flags, force_nonfallthru(), ggc_alloc(), INSN_LOCATION(), last, NEXT_INSN(), NONDEBUG_INSN_P, PREV_INSN(), and update_bb_for_insn().

Referenced by dw2_build_landing_pads(), and sjlj_emit_dispatch_table().

◆ expand_builtin_eh_common()

static eh_region expand_builtin_eh_common ( tree region_nr_t)
static
Various hooks for unwind library.   
Expand the EH support builtin functions:
__builtin_eh_pointer and __builtin_eh_filter.   

References cfun, gcc_assert, ggc_alloc(), NULL, tree_fits_shwi_p(), and tree_to_shwi().

Referenced by expand_builtin_eh_copy_values(), expand_builtin_eh_filter(), and expand_builtin_eh_pointer().

◆ expand_builtin_eh_copy_values()

rtx expand_builtin_eh_copy_values ( tree exp)
Copy the exc_ptr and filter values from one landing pad's registers
to another.  This is used to inline the resx statement.   

References CALL_EXPR_ARG, const0_rtx, emit_move_insn(), eh_region_d::exc_ptr_reg, exp(), expand_builtin_eh_common(), eh_region_d::filter_reg, gen_reg_rtx(), ggc_alloc(), NULL, ptr_mode, and targetm.

Referenced by expand_builtin().

◆ expand_builtin_eh_filter()

rtx expand_builtin_eh_filter ( tree exp)
Expand to the filter value from the given eh region.   

References CALL_EXPR_ARG, exp(), expand_builtin_eh_common(), eh_region_d::filter_reg, gen_reg_rtx(), NULL, and targetm.

Referenced by expand_builtin().

◆ expand_builtin_eh_pointer()

rtx expand_builtin_eh_pointer ( tree exp)
Expand to the exc_ptr value from the given eh region.   

References CALL_EXPR_ARG, eh_region_d::exc_ptr_reg, exp(), expand_builtin_eh_common(), gen_reg_rtx(), NULL, and ptr_mode.

Referenced by expand_builtin().

◆ expand_builtin_eh_return()

void expand_builtin_eh_return ( tree stackadj_tree,
tree handler_tree )
Set up the epilogue with the magic bits we'll need to return to the
exception handler.   

References convert_memory_address, copy_addr_to_reg(), crtl, emit_jump(), emit_move_insn(), expand_expr(), EXPAND_NORMAL, gen_label_rtx(), and ggc_alloc().

Referenced by expand_builtin().

◆ expand_builtin_eh_return_data_regno()

rtx expand_builtin_eh_return_data_regno ( tree exp)
Map a non-negative number to an eh return data register number; expands
to -1 if no return data register is associated with the input number.
At least the inputs 0 and 1 must be mapped; the target may provide more.   

References CALL_EXPR_ARG, constm1_rtx, DEBUGGER_REGNO, DWARF_FRAME_REGNUM, EH_RETURN_DATA_REGNO, error(), exp(), GEN_INT, ggc_alloc(), INVALID_REGNUM, TREE_CODE, tree_fits_uhwi_p(), and tree_to_uhwi().

Referenced by expand_builtin().

◆ expand_builtin_extend_pointer()

rtx expand_builtin_extend_pointer ( tree addr_tree)
Convert a ptr_mode address ADDR_TREE to a Pmode address controlled by
POINTERS_EXTEND_UNSIGNED and return it.   

References convert_modes(), expand_expr(), EXPAND_NORMAL, ggc_alloc(), NULL_RTX, ptr_mode, and targetm.

Referenced by expand_builtin().

◆ expand_builtin_extract_return_addr()

rtx expand_builtin_extract_return_addr ( tree addr_tree)
Given a value extracted from the return address register or stack slot,
return the actual address encoded in that value.   

References convert_memory_address, convert_to_mode(), expand_and(), expand_expr(), EXPAND_NORMAL, GET_MODE, ggc_alloc(), MASK_RETURN_ADDR, NULL_RTX, plus_constant(), and RETURN_ADDR_OFFSET.

Referenced by expand_builtin().

◆ expand_builtin_frob_return_addr()

rtx expand_builtin_frob_return_addr ( tree addr_tree)
Given an actual address in addr_tree, do any necessary encoding
and return the value to be stored in the return address register or
stack slot so the epilogue will return to that address.   

References convert_memory_address, expand_expr(), EXPAND_NORMAL, force_reg(), ggc_alloc(), NULL_RTX, plus_constant(), ptr_mode, and RETURN_ADDR_OFFSET.

Referenced by expand_builtin().

◆ expand_builtin_unwind_init()

void expand_builtin_unwind_init ( void )
Do any necessary initialization to access arbitrary stack frames.
On the SPARC, this means flushing the register windows.   

References crtl, and SETUP_FRAME_ADDRESSES.

Referenced by expand_builtin().

◆ expand_dw2_landing_pad_for_region()

static void expand_dw2_landing_pad_for_region ( eh_region region)
static
A subroutine of dw2_build_landing_pads, also used for edge splitting
at the rtl level.  Emit the code required by the target at a landing
pad for the given region.   

References EH_RETURN_DATA_REGNO, emit_insn(), emit_move_insn(), eh_region_d::exc_ptr_reg, eh_region_d::filter_reg, gen_rtx_REG(), ptr_mode, and targetm.

Referenced by dw2_build_landing_pads().

◆ expand_eh_return()

void expand_eh_return ( void )
Expand __builtin_eh_return.  This exit path from the function loads up
the eh return data registers, adjusts the stack, and branches to a
given PC other than the normal return address.   

References clobber_return_register(), const0_rtx, const1_rtx, crtl, EH_RETURN_HANDLER_RTX, emit_clobber(), emit_insn(), emit_jump(), emit_label(), emit_move_insn(), error(), gen_label_rtx(), ggc_alloc(), REG_P, and targetm.

Referenced by expand_function_end().

◆ finish_eh_generation()

◆ for_each_eh_label()

void for_each_eh_label ( void(*)(rtx) callback)
Invokes CALLBACK for every exception handler landing pad label.
Only used by reload hackery; should not be used by new code.   

References cfun, ggc_alloc(), i, LABEL_P, eh_landing_pad_d::landing_pad, and vec_safe_iterate().

Referenced by set_initial_label_offsets().

◆ function_needs_eh_personality()

◆ gen_eh_landing_pad()

◆ gen_eh_region()

static eh_region gen_eh_region ( enum eh_region_type type,
eh_region outer )
static
Routines to generate the exception tree somewhat directly.
These are used from tree-eh.cc when processing exception related
nodes during tree optimization.   

References cfun, lang_hooks::eh_use_cxa_end_cleanup, ggc_alloc(), eh_region_d::inner, targetm, type(), vec_safe_length(), and vec_safe_push().

Referenced by duplicate_eh_regions_1(), gen_eh_region_allowed(), gen_eh_region_cleanup(), gen_eh_region_must_not_throw(), and gen_eh_region_try().

◆ gen_eh_region_allowed()

◆ gen_eh_region_catch()

◆ gen_eh_region_cleanup()

eh_region gen_eh_region_cleanup ( eh_region outer)

◆ gen_eh_region_must_not_throw()

eh_region gen_eh_region_must_not_throw ( eh_region outer)

◆ gen_eh_region_try()

eh_region gen_eh_region_try ( eh_region outer)

References ERT_TRY, and gen_eh_region().

Referenced by lower_catch().

◆ get_eh_landing_pad_from_number()

◆ get_eh_landing_pad_from_number_fn()

eh_landing_pad get_eh_landing_pad_from_number_fn ( struct function * ifun,
int i )

References ggc_alloc(), and i.

Referenced by get_eh_landing_pad_from_number().

◆ get_eh_landing_pad_from_rtx()

eh_landing_pad get_eh_landing_pad_from_rtx ( const_rtx insn)
Return the landing pad to which INSN may go, or NULL if it does not
have a reachable landing pad within this function.   

References get_eh_region_and_lp_from_rtx(), and r.

Referenced by can_throw_internal(), create_trace_edges(), finish_eh_generation(), and rtl_make_eh_edge().

◆ get_eh_region_and_lp_from_rtx()

static bool get_eh_region_and_lp_from_rtx ( const_rtx insn,
eh_region * pr,
eh_landing_pad * plp )
static

◆ get_eh_region_from_lp_number()

◆ get_eh_region_from_lp_number_fn()

eh_region get_eh_region_from_lp_number_fn ( struct function * ifun,
int i )

◆ get_eh_region_from_number()

◆ get_eh_region_from_number_fn()

eh_region get_eh_region_from_number_fn ( struct function * ifun,
int i )

References ggc_alloc(), and i.

Referenced by get_eh_region_from_number(), and remap_eh_region_nr().

◆ get_eh_region_from_rtx()

eh_region get_eh_region_from_rtx ( const_rtx insn)
Return the region to which INSN may go, or NULL if it does not
have a reachable region within this function.   

References get_eh_region_and_lp_from_rtx(), and r.

Referenced by process_bb_node_lives().

◆ get_eh_throw_stmt_table()

hash_map< gimple *, int > * get_eh_throw_stmt_table ( struct function * fun)

◆ init_eh()

◆ init_eh_for_function()

void init_eh_for_function ( void )

◆ insn_could_throw_p()

bool insn_could_throw_p ( const_rtx insn)

◆ insn_nothrow_p()

◆ lookup_type_for_runtime()

tree lookup_type_for_runtime ( tree type)

◆ make_pass_convert_to_eh_region_ranges()

rtl_opt_pass * make_pass_convert_to_eh_region_ranges ( gcc::context * ctxt)

References ggc_alloc().

◆ make_pass_set_nothrow_function_flags()

rtl_opt_pass * make_pass_set_nothrow_function_flags ( gcc::context * ctxt)

References ggc_alloc().

◆ make_reg_eh_region_note()

void make_reg_eh_region_note ( rtx_insn * insn,
int ecf_flags,
int lp_nr )
Create the REG_EH_REGION note for INSN, given its ECF_FLAGS for a
 call insn.

 At the gimple level, we use LP_NR
     > 0 : The statement transfers to landing pad LP_NR
     = 0 : The statement is outside any EH region
     < 0 : The statement is within MUST_NOT_THROW region -LP_NR.

 At the rtl level, we use LP_NR
     > 0 : The insn transfers to landing pad LP_NR
     = 0 : The insn cannot throw
     < 0 : The insn is within MUST_NOT_THROW region -LP_NR
     = INT_MIN : The insn cannot throw or execute a nonlocal-goto.
     missing note: The insn is outside any EH region.

??? This difference probably ought to be avoided.  We could stand
to record nothrow for arbitrary gimple statements, and so avoid
some moderately complex lookups in stmt_could_throw_p.  Perhaps
NOTHROW should be mapped on both sides to INT_MIN.  Perhaps the
no-nonlocal-goto property should be recorded elsewhere as a bit
on the call_insn directly.  Perhaps we should make more use of
attaching the trees to call_insns (reachable via symbol_ref in
direct call cases) and just pull the data out of the trees.   

References add_reg_note(), const0_rtx, ECF_NOTHROW, GEN_INT, and ggc_alloc().

Referenced by emit_call_1(), and expand_gimple_stmt().

◆ make_reg_eh_region_note_nothrow_nononlocal()

void make_reg_eh_region_note_nothrow_nononlocal ( rtx_insn * insn)
Create a REG_EH_REGION note for a CALL_INSN that cannot throw
nor perform a non-local goto.  Replace the region note if it
already exists.   

References add_reg_note(), find_reg_note(), GEN_INT, ggc_alloc(), INT_MIN, NULL_RTX, and XEXP.

Referenced by emit_libcall_block_1(), and emit_library_call_value_1().

◆ maybe_add_nop_after_section_switch()

static bool maybe_add_nop_after_section_switch ( void )
static
Add NOP after NOTE_INSN_SWITCH_TEXT_SECTIONS when the cold section starts
with landing pad.
With landing pad being at offset 0 from the start label of the section
we would miss EH delivery because 0 is special and means no landing pad.   

References active_insn_p(), crtl, emit_insn_after(), GET_CODE, ggc_alloc(), i, LABEL_P, LABEL_PRESERVE_P, call_site_record_d::landing_pad, NOTE_KIND, PATTERN(), PREV_INSN(), vec_safe_length(), and visited.

◆ output_function_exception_table()

void output_function_exception_table ( int section)
Output an exception table for the current function according to SECTION,
switching back and forth from the function section appropriately.

If the function has been partitioned into hot and cold parts, value 0 for
SECTION refers to the table associated with the hot part while value 1
refers to the table associated with the cold part.  If the function has
not been partitioned, value 0 refers to the single exception table.   

References asm_out_file, assemble_external_libcall(), crtl, current_function_decl, current_function_section(), get_fnname_from_decl(), get_personality_function(), ggc_alloc(), global_options, output_one_function_exception_table(), switch_to_exception_section(), switch_to_section(), targetm, and UI_NONE.

Referenced by final_scan_insn_1(), and rest_of_handle_final().

◆ output_one_function_exception_table()

static void output_one_function_exception_table ( int section)
static
Output an exception table for the current function according to SECTION.

If the function has been partitioned into hot and cold parts, value 0 for
SECTION refers to the table associated with the hot part while value 1
refers to the table associated with the cold part.  If the function has
not been partitioned, value 0 refers to the single exception table.   

References asm_out_file, ASM_OUTPUT_LABEL, ASM_PREFERRED_EH_DATA_FORMAT, assemble_align(), cfun, crtl, current_function_funcdef_no, dw2_asm_output_data(), dw2_asm_output_data_uleb128(), dw2_asm_output_delta_uleb128(), dw2_output_call_site_table(), dw2_size_of_call_site_table(), eh_data_format_name(), FOR_EACH_VEC_ELT, ggc_alloc(), global_options, i, NULL, output_ttype(), size_of_encoded_value(), size_of_uleb128(), sjlj_output_call_site_table(), sjlj_size_of_call_site_table(), targetm, type(), uc, UI_SJLJ, vec_safe_iterate(), and vec_safe_length().

Referenced by output_function_exception_table().

◆ output_ttype()

static void output_ttype ( tree type,
int tt_format,
int tt_format_size )
static
Output a reference from an exception table to the type_info object TYPE.
TT_FORMAT and TT_FORMAT_SIZE describe the DWARF encoding method used for
the value.   

References assemble_integer(), const0_rtx, dw2_asm_output_encoded_addr_rtx(), expand_expr(), EXPAND_INITIALIZER, gcc_assert, ggc_alloc(), lookup_type_for_runtime(), NULL, NULL_RTX, NULL_TREE, STRIP_NOPS, targetm, TREE_CODE, TREE_OPERAND, TREE_PUBLIC, TYPE_P, and VAR_P.

Referenced by output_one_function_exception_table().

◆ push_sleb128()

static void push_sleb128 ( vec< uchar, va_gc > ** data_area,
int value )
static

References ggc_alloc(), and vec_safe_push().

Referenced by add_action_record().

◆ push_uleb128()

static void push_uleb128 ( vec< uchar, va_gc > ** data_area,
unsigned int value )
static

References ggc_alloc(), and vec_safe_push().

Referenced by add_ehspec_entry().

◆ remove_eh_handler()

void remove_eh_handler ( eh_region region)
Splice a single EH region REGION from the region tree.

To unlink REGION, we need to find the pointer to it with a relatively
expensive search in REGION's outer region.  If you are going to
remove a number of handlers, using remove_unreachable_eh_regions may
be a better option.   

References cfun, ggc_alloc(), eh_region_d::inner, eh_region_d::next_peer, eh_region_d::outer, and remove_eh_handler_splicer().

◆ remove_eh_handler_splicer()

◆ remove_eh_landing_pad()

◆ remove_unreachable_eh_regions()

void remove_unreachable_eh_regions ( sbitmap r_reachable)
Splice all EH regions *not* marked in R_REACHABLE from the region tree.
Do this by traversing the EH tree top-down and splice out regions that
are not marked.  By removing regions from the leaves, we avoid costly
searches in the region tree.   

References cfun, ggc_alloc(), and remove_unreachable_eh_regions_worker().

Referenced by remove_unreachable_handlers(), and remove_unreachable_handlers_no_lp().

◆ remove_unreachable_eh_regions_worker()

static void remove_unreachable_eh_regions_worker ( eh_region * pp,
sbitmap r_reachable )
static
Worker for remove_unreachable_eh_regions.
PP is a pointer to the region to start a region tree depth-first
search from.  R_REACHABLE is the set of regions that have to be
preserved.   

References bitmap_bit_p, ggc_alloc(), eh_region_d::index, eh_region_d::inner, eh_region_d::next_peer, remove_eh_handler_splicer(), and remove_unreachable_eh_regions_worker().

Referenced by remove_unreachable_eh_regions(), and remove_unreachable_eh_regions_worker().

◆ set_eh_throw_stmt_table()

void set_eh_throw_stmt_table ( function * fun,
hash_map< gimple *, int > * table )

◆ set_nothrow_function_flags()

◆ sjlj_assign_call_site_values()

static int sjlj_assign_call_site_values ( void )
static
Process all active landing pads.  Assign each one a compact dispatch
index, and a call-site index.   

References add_call_site(), call_site_base, cfun, collect_one_action_chain(), crtl, GEN_INT, ggc_alloc(), i, eh_landing_pad_d::post_landing_pad, eh_landing_pad_d::region, sjlj_lp_call_site_index, vec_alloc(), and vec_safe_iterate().

Referenced by sjlj_build_landing_pads().

◆ sjlj_build_landing_pads()

◆ sjlj_emit_dispatch_table()

◆ sjlj_emit_function_enter()

◆ sjlj_emit_function_exit()

◆ sjlj_emit_function_exit_after()

void sjlj_emit_function_exit_after ( rtx_insn * after)
Call back from expand_function_end to know where we should put
the call to unwind_sjlj_unregister_libfunc if needed.   

References crtl, and ggc_alloc().

Referenced by expand_function_end().

◆ sjlj_mark_call_sites()

◆ sjlj_output_call_site_table()

◆ sjlj_size_of_call_site_table()

◆ switch_to_exception_section()

static void switch_to_exception_section ( const char * ARG_UNUSEDfnname)
static

◆ update_sjlj_context()

void update_sjlj_context ( void )
Update the sjlj function context.  This function should be called
whenever we allocate or deallocate dynamic stack space.   

References emit_note(), and ggc_alloc().

Referenced by record_new_stack_level().

◆ verify_eh_tree()

Variable Documentation

◆ call_site_base

int call_site_base
static
Implements exception handling.
   Copyright (C) 1989-2024 Free Software Foundation, Inc.
   Contributed by Mike Stump <mrs@cygnus.com>.

This file is part of GCC.

GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.

GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3.  If not see
<http://www.gnu.org/licenses/>.   
An exception is an event that can be "thrown" from within a
function.  This event can then be "caught" by the callers of
the function.

The representation of exceptions changes several times during
the compilation process:

In the beginning, in the front end, we have the GENERIC trees
TRY_CATCH_EXPR, TRY_FINALLY_EXPR, EH_ELSE_EXPR, WITH_CLEANUP_EXPR,
CLEANUP_POINT_EXPR, CATCH_EXPR, and EH_FILTER_EXPR.

During initial gimplification (gimplify.cc) these are lowered to the
GIMPLE_TRY, GIMPLE_CATCH, GIMPLE_EH_ELSE, and GIMPLE_EH_FILTER
nodes.  The WITH_CLEANUP_EXPR and CLEANUP_POINT_EXPR nodes are
converted into GIMPLE_TRY_FINALLY nodes; the others are a more
direct 1-1 conversion.

During pass_lower_eh (tree-eh.cc) we record the nested structure
of the TRY nodes in EH_REGION nodes in CFUN->EH->REGION_TREE.
We expand the eh_protect_cleanup_actions langhook into MUST_NOT_THROW
regions at this time.  We can then flatten the statements within
the TRY nodes to straight-line code.  Statements that had been within
TRY nodes that can throw are recorded within CFUN->EH->THROW_STMT_TABLE,
so that we may remember what action is supposed to be taken if
a given statement does throw.  During this lowering process,
we create an EH_LANDING_PAD node for each EH_REGION that has
some code within the function that needs to be executed if a
throw does happen.  We also create RESX statements that are
used to transfer control from an inner EH_REGION to an outer
EH_REGION.  We also create EH_DISPATCH statements as placeholders
for a runtime type comparison that should be made in order to
select the action to perform among different CATCH and EH_FILTER
regions.

During pass_lower_eh_dispatch (tree-eh.cc), which is run after
all inlining is complete, we are able to run assign_filter_values,
which allows us to map the set of types manipulated by all of the
CATCH and EH_FILTER regions to a set of integers.  This set of integers
will be how the exception runtime communicates with the code generated
within the function.  We then expand the GIMPLE_EH_DISPATCH statements
to a switch or conditional branches that use the argument provided by
the runtime (__builtin_eh_filter) and the set of integers we computed
in assign_filter_values.

During pass_lower_resx (tree-eh.cc), which is run near the end
of optimization, we expand RESX statements.  If the eh region
that is outer to the RESX statement is a MUST_NOT_THROW, then
the RESX expands to some form of abort statement.  If the eh
region that is outer to the RESX statement is within the current
function, then the RESX expands to a bookkeeping call
(__builtin_eh_copy_values) and a goto.  Otherwise, the next
handler for the exception must be within a function somewhere
up the call chain, so we call back into the exception runtime
(__builtin_unwind_resume).

During pass_expand (cfgexpand.cc), we generate REG_EH_REGION notes
that create an rtl to eh_region mapping that corresponds to the
gimple to eh_region mapping that had been recorded in the
THROW_STMT_TABLE.

Then, via finish_eh_generation, we generate the real landing pads
to which the runtime will actually transfer control.  These new
landing pads perform whatever bookkeeping is needed by the target
backend in order to resume execution within the current function.
Each of these new landing pads falls through into the post_landing_pad
label which had been used within the CFG up to this point.  All
exception edges within the CFG are redirected to the new landing pads.
If the target uses setjmp to implement exceptions, the various extra
calls into the runtime to register and unregister the current stack
frame are emitted at this time.

During pass_convert_to_eh_region_ranges (except.cc), we transform
the REG_EH_REGION notes attached to individual insns into
non-overlapping ranges of insns bounded by NOTE_INSN_EH_REGION_BEG
and NOTE_INSN_EH_REGION_END.  Each insn within such ranges has the
same associated action within the exception region tree, meaning
that (1) the exception is caught by the same landing pad within the
current function, (2) the exception is blocked by the runtime with
a MUST_NOT_THROW region, or (3) the exception is not handled at all
within the current function.

Finally, during assembly generation, we call
output_function_exception_table (except.cc) to emit the tables with
which the exception runtime can determine if a given stack frame
handles a given exception, and if so what filter value to provide
to the function when the non-local control transfer is effected.
If the target uses dwarf2 unwinding to implement exceptions, then
output_call_frame_info (dwarf2out.cc) emits the required unwind data.   

Referenced by add_call_site(), convert_to_eh_region_ranges(), dw2_output_call_site_table(), sjlj_assign_call_site_values(), and sjlj_output_call_site_table().

◆ setjmp_fn

tree setjmp_fn
static

◆ sjlj_fc_call_site_ofs

int sjlj_fc_call_site_ofs
static

◆ sjlj_fc_data_ofs

int sjlj_fc_data_ofs
static

◆ sjlj_fc_jbuf_ofs

int sjlj_fc_jbuf_ofs
static

◆ sjlj_fc_lsda_ofs

int sjlj_fc_lsda_ofs
static

◆ sjlj_fc_personality_ofs

int sjlj_fc_personality_ofs
static

◆ sjlj_fc_type_node

tree sjlj_fc_type_node
static
Describe the SjLj_Function_Context structure.   

Referenced by init_eh(), and sjlj_build_landing_pads().

◆ sjlj_lp_call_site_index

vec<int> sjlj_lp_call_site_index
static

◆ type_to_runtime_map

hash_map<tree_hash, tree>* type_to_runtime_map
static