GCC Middle and Back End API 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"
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 |
Macros | |
#define | INCLUDE_MEMORY |
Typedefs | |
typedef hash_table< action_record_hasher > | action_hash_type |
typedef hash_table< ttypes_filter_hasher > | ttypes_hash_type |
typedef hash_table< ehspec_hasher > | ehspec_hash_type |
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 |
#define INCLUDE_MEMORY |
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.
typedef hash_table<ehspec_hasher> ehspec_hash_type |
|
static |
References crtl, action_record::filter, hash_table< Descriptor, Lazy, Allocator >::find_slot(), action_record::next, NULL, action_record::offset, and push_sleb128().
Referenced by collect_one_action_chain().
|
static |
References call_site_record_d::action, call_site_base, crtl, ggc_alloc(), call_site_record_d::landing_pad, and vec_safe_push().
Referenced by convert_to_eh_region_ranges(), and sjlj_assign_call_site_values().
|
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, hash_table< Descriptor, Lazy, Allocator >::find_slot(), 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().
|
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, hash_table< Descriptor, Lazy, Allocator >::find_slot_with_hash(), NULL, ttypes_filter::t, TREE_HASH, type(), vec_safe_length(), and vec_safe_push().
Referenced by add_ehspec_entry(), and assign_filter_values().
void add_type_for_runtime | ( | tree | type | ) |
References lang_hooks::eh_runtime_type, TREE_CODE, and type_to_runtime_map.
Referenced by gen_eh_region_allowed(), gen_eh_region_catch(), input_eh_region(), and lto_input_eh_catch_list().
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, 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().
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(), 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().
Return true if INSN throws and escapes from the current function.
References as_a(), can_throw_external(), rtx_sequence::element(), ERT_MUST_NOT_THROW, gcc_assert, GET_CODE, get_eh_region_and_lp_from_rtx(), i, INSN_P, rtx_sequence::len(), NONJUMP_INSN_P, NULL, PATTERN(), and r.
Referenced by can_throw_external(), compute_hash_table_work(), record_opr_changes(), and set_nothrow_function_flags().
Return true if INSN throws and is caught by something in this function.
References get_eh_landing_pad_from_rtx(), and NULL.
Referenced by combine_and_move_insns(), control_flow_insn_p(), cse_insn(), decompose_multiword_subregs(), fill_simple_delay_slots(), fill_slots_from_thread(), find_invariant_insn(), fixup_abnormal_edges(), hash_scan_set(), merge_if_block(), move_insn_for_shrink_wrap(), optimize_skip(), peep2_attempt(), process_bb_node_lives(), purge_dead_edges(), relax_delay_slots(), remove_init_insns(), requires_stack_frame_p(), scan_trace(), stop_search_p(), and will_delete_init_insn_p().
|
static |
References add_action_record(), eh_region_d::eh_region_u::allowed, collect_one_action_chain(), eh_region_d::eh_region_u::eh_try, ERT_ALLOWED_EXCEPTIONS, ERT_CLEANUP, ERT_MUST_NOT_THROW, ERT_TRY, action_record::filter, eh_region_d::eh_region_u::eh_region_u_allowed::filter, eh_catch_d::filter_list, gcc_unreachable, eh_region_d::eh_region_u::eh_region_u_try::last_catch, action_record::next, NULL, eh_region_d::outer, eh_catch_d::prev_catch, r, TREE_CHAIN, TREE_INT_CST_LOW, TREE_VALUE, eh_region_d::type, eh_catch_d::type_list, and eh_region_d::u.
Referenced by collect_one_action_chain(), convert_to_eh_region_ranges(), and sjlj_assign_call_site_values().
|
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(), 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.
Likewise, but iterate backward.
References add_reg_note(), find_reg_note(), insn_could_throw_p(), INSN_P, is_a(), last, NULL, NULL_RTX, PREV_INSN(), and XEXP.
Referenced by peep2_attempt(), and try_split().
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(), insn_could_throw_p(), INSN_P, is_a(), 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().
bool current_function_has_exception_handlers | ( | void | ) |
Returns true if the current function has exception handling regions.
Referenced by suitable_for_tail_call_opt_p().
DEBUG_FUNCTION void debug_eh_tree | ( | struct function * | fn | ) |
Dump the EH tree for FN on stderr.
References dump_eh_tree().
void dump_eh_tree | ( | FILE * | out, |
struct function * | fun ) |
Dump EH information to OUT.
References current_ir_type(), function::eh, ERT_ALLOWED_EXCEPTIONS, ERT_CLEANUP, ERT_MUST_NOT_THROW, ERT_TRY, fputc(), i, eh_landing_pad_d::index, INSN_UID(), IR_GIMPLE, eh_catch_d::label, label_rtx(), eh_landing_pad_d::landing_pad, eh_catch_d::next_catch, eh_landing_pad_d::next_lp, NOTE_P, NULL, eh_landing_pad_d::post_landing_pad, print_generic_expr(), eh_status::region_tree, and eh_catch_d::type_list.
Referenced by debug_eh_tree(), dump_function_to_file(), remove_unreachable_handlers(), and verify_eh_tree().
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(), function::eh, get_eh_region_from_lp_number_fn(), map, eh_region_d::next_peer, r, eh_status::region_tree, and verify_eh_tree().
Referenced by copy_cfg_body(), and move_sese_region_to_fn().
|
static |
References eh_region_d::eh_region_u::allowed, duplicate_eh_regions_1(), EH_LANDING_PAD_NR, eh_region_d::eh_region_u::eh_try, ERT_ALLOWED_EXCEPTIONS, ERT_CLEANUP, ERT_MUST_NOT_THROW, ERT_TRY, eh_region_d::eh_region_u::eh_region_u_must_not_throw::failure_decl, eh_region_d::eh_region_u::eh_region_u_must_not_throw::failure_loc, eh_catch_d::filter_list, eh_region_d::eh_region_u::eh_region_u_try::first_catch, gcc_assert, gen_eh_landing_pad(), gen_eh_region(), gen_eh_region_catch(), eh_landing_pad_d::index, eh_region_d::inner, eh_catch_d::label, eh_region_d::eh_region_u::eh_region_u_allowed::label, eh_region_d::landing_pads, LOCATION_LOCUS, eh_region_d::eh_region_u::must_not_throw, eh_catch_d::next_catch, eh_landing_pad_d::next_lp, eh_region_d::next_peer, NULL, NULL_TREE, eh_landing_pad_d::post_landing_pad, eh_region_d::type, eh_catch_d::type_list, eh_region_d::eh_region_u::eh_region_u_allowed::type_list, eh_region_d::u, and eh_region_d::use_cxa_end_cleanup.
Referenced by duplicate_eh_regions(), and duplicate_eh_regions_1().
|
static |
Expand the extra code needed at landing pads for dwarf2 unwinding.
References add_bb_to_loop(), cfun, basic_block_def::count, current_loops, emit_label(), emit_to_new_bb_before(), end_sequence(), expand_dw2_landing_pad_for_region(), gen_label_rtx(), get_insns(), loop::header, i, LABEL_PRESERVE_P, label_rtx(), eh_landing_pad_d::landing_pad, basic_block_def::loop_father, loop_outer(), make_single_succ_edge(), basic_block_def::next_bb, NULL, eh_landing_pad_d::post_landing_pad, eh_landing_pad_d::region, start_sequence(), and vec_safe_iterate().
Referenced by finish_eh_generation().
|
static |
References call_site_record_d::action, begin(), call_site_base, CODE_LABEL_NUMBER, crtl, current_function_func_begin_label, dw2_asm_output_data(), dw2_asm_output_data_uleb128(), dw2_asm_output_delta(), dw2_asm_output_delta_uleb128(), first_function_block_is_cold, i, call_site_record_d::landing_pad, and vec_safe_length().
Referenced by output_one_function_exception_table().
|
static |
References call_site_record_d::action, crtl, i, size_of_uleb128(), and vec_safe_length().
Referenced by output_one_function_exception_table().
Return the region that is outer to both REGION_A and REGION_B in IFUN.
References bitmap_bit_p, bitmap_clear(), bitmap_set_bit, function::eh, gcc_assert, eh_region_d::index, eh_region_d::outer, eh_status::region_array, and eh_status::region_tree.
Referenced by find_outermost_region_in_block().
References emit_note_after().
Referenced by convert_to_eh_region_ranges().
|
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(), 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().
Various hooks for unwind library.
Expand the EH support builtin functions: __builtin_eh_pointer and __builtin_eh_filter.
References cfun, gcc_assert, 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().
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(), NULL, ptr_mode, and targetm.
Referenced by expand_builtin().
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 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().
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, and gen_label_rtx().
Referenced by expand_builtin().
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, INVALID_REGNUM, TREE_CODE, tree_fits_uhwi_p(), and tree_to_uhwi().
Referenced by expand_builtin().
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, NULL_RTX, ptr_mode, and targetm.
Referenced by expand_builtin().
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, MASK_RETURN_ADDR, NULL_RTX, plus_constant(), and RETURN_ADDR_OFFSET.
Referenced by expand_builtin().
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(), NULL_RTX, plus_constant(), ptr_mode, and RETURN_ADDR_OFFSET.
Referenced by expand_builtin().
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().
|
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().
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(), REG_P, and targetm.
Referenced by expand_function_end().
void finish_eh_generation | ( | void | ) |
After initial rtl generation, call back to finish generating exception support code.
References BB_END, BB_HEAD, BLOCK_FOR_INSN(), break_superblocks(), CALL_P, cfun, commit_edge_insertions(), dw2_build_landing_pads(), ENTRY_BLOCK_PTR_FOR_FN, FOR_EACH_BB_FN, FOR_EACH_EDGE, gcc_assert, get_eh_landing_pad_from_rtx(), global_options, insns, label_rtx(), eh_landing_pad_d::landing_pad, NULL, eh_landing_pad_d::post_landing_pad, redirect_edge_succ(), single_succ_edge(), sjlj_build_landing_pads(), basic_block_def::succs, and UI_SJLJ.
void for_each_eh_label | ( | void(* | callback )(rtx) | ) |
Invokes CALLBACK for every exception handler landing pad label. Only used by reload hackery; should not be used by new code.
References cfun, i, LABEL_P, eh_landing_pad_d::landing_pad, and vec_safe_iterate().
Referenced by set_initial_label_offsets().
enum eh_personality_kind function_needs_eh_personality | ( | struct function * | fn | ) |
Determine if the function needs an EH personality function.
References eh_personality_any, eh_personality_lang, eh_personality_none, ERT_ALLOWED_EXCEPTIONS, ERT_CLEANUP, ERT_MUST_NOT_THROW, ERT_TRY, FOR_ALL_EH_REGION_FN, and i.
Referenced by cgraph_node::add_new_function(), get_personality_function(), and sjlj_build_landing_pads().
eh_landing_pad gen_eh_landing_pad | ( | eh_region | region | ) |
References cfun, ggc_cleared_alloc(), eh_landing_pad_d::index, eh_region_d::landing_pads, eh_landing_pad_d::next_lp, eh_landing_pad_d::region, vec_safe_length(), and vec_safe_push().
Referenced by duplicate_eh_regions_1(), dw2_fix_up_crossing_landing_pad(), emit_post_landing_pad(), gsi_insert_finally_seq_after_call(), record_stmt_eh_region(), redirect_eh_edge_1(), and sjlj_fix_up_crossing_landing_pad().
|
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_cleared_alloc(), eh_region_d::index, eh_region_d::inner, eh_region_d::next_peer, eh_region_d::outer, targetm, eh_region_d::type, type(), eh_region_d::use_cxa_end_cleanup, 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().
References add_type_for_runtime(), eh_region_d::eh_region_u::eh_try, ERT_TRY, eh_region_d::eh_region_u::eh_region_u_try::first_catch, gcc_assert, ggc_cleared_alloc(), eh_region_d::eh_region_u::eh_region_u_try::last_catch, eh_catch_d::next_catch, NULL_TREE, eh_catch_d::prev_catch, TREE_CHAIN, TREE_CODE, tree_cons(), TREE_VALUE, eh_region_d::type, eh_catch_d::type_list, and eh_region_d::u.
Referenced by duplicate_eh_regions_1(), and lower_catch().
References ERT_CLEANUP, and gen_eh_region().
Referenced by gsi_insert_finally_seq_after_call(), lower_cleanup(), and lower_try_finally().
References ERT_MUST_NOT_THROW, and gen_eh_region().
Referenced by lower_eh_must_not_throw().
References ERT_TRY, and gen_eh_region().
Referenced by lower_catch().
eh_landing_pad get_eh_landing_pad_from_number | ( | int | i | ) |
References cfun, get_eh_landing_pad_from_number_fn(), and i.
Referenced by gimple_merge_blocks(), lower_resx(), make_eh_edge(), redirect_eh_edge_1(), verify_eh_edges(), and verify_gimple_label().
eh_landing_pad get_eh_landing_pad_from_number_fn | ( | struct function * | ifun, |
int | i ) |
References function::eh, i, and eh_status::lp_array.
Referenced by get_eh_landing_pad_from_number().
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().
|
static |
Extract all EH information from INSN. Return true if the insn was marked NOTHROW.
References cfun, find_reg_note(), GET_CODE, insn_could_throw_p(), INSN_P, INT_MIN, INTVAL, NONJUMP_INSN_P, NULL, NULL_RTX, PATTERN(), r, eh_landing_pad_d::region, XEXP, and XVECEXP.
Referenced by can_throw_external(), convert_to_eh_region_ranges(), get_eh_landing_pad_from_rtx(), get_eh_region_from_rtx(), insn_nothrow_p(), and sjlj_mark_call_sites().
eh_region get_eh_region_from_lp_number | ( | int | i | ) |
References cfun, get_eh_region_from_lp_number_fn(), and i.
Referenced by cleanup_empty_eh(), cleanup_empty_eh_unsplit(), lower_resx(), mark_reachable_handlers(), and unsplit_eh().
References function::eh, i, eh_status::lp_array, NULL, eh_landing_pad_d::region, and eh_status::region_array.
Referenced by duplicate_eh_regions(), find_outermost_region_in_block(), and get_eh_region_from_lp_number().
eh_region get_eh_region_from_number | ( | int | i | ) |
References cfun, get_eh_region_from_number_fn(), and i.
Referenced by lower_eh_dispatch(), lower_resx(), make_eh_dispatch_edges(), move_stmt_eh_region_nr(), redirect_eh_dispatch_edge(), and verify_eh_dispatch_edge().
References function::eh, i, and eh_status::region_array.
Referenced by get_eh_region_from_number(), and remap_eh_region_nr().
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().
References function::eh, and eh_status::throw_stmt_table.
Referenced by add_stmt_to_eh_lp_fn(), remove_stmt_from_eh_lp_fn(), and verify_gimple_in_cfg().
void init_eh | ( | void | ) |
In except.cc. Initialize exception handling. This is used by the Ada and LTO front ends to initialize EH "on demand". See lto-streamer-in.cc and ada/gcc-interface/misc.cc.
References BITS_PER_WORD, build_array_type(), build_decl(), build_function_type_list(), build_index_type(), build_pointer_type(), BUILTINS_LOCATION, hash_map< KeyId, Value, Traits >::create_ggc(), DECL_ASSEMBLER_NAME, DECL_EXTERNAL, DECL_FIELD_BIT_OFFSET, DECL_FIELD_CONTEXT, DECL_FIELD_OFFSET, DECL_USER_ALIGN, get_identifier(), global_options, integer_type_node, layout_type(), lang_hooks_for_types::make_type, NULL, POINTER_SIZE, ptr_type_node, SET_DECL_ALIGN, setjmp_fn, size_int, sjlj_fc_call_site_ofs, sjlj_fc_data_ofs, sjlj_fc_jbuf_ofs, sjlj_fc_lsda_ofs, sjlj_fc_personality_ofs, sjlj_fc_type_node, targetm, TREE_CHAIN, TREE_PUBLIC, tree_to_uhwi(), TREE_TYPE, TYPE_FIELDS, lang_hooks_for_types::type_for_mode, type_to_runtime_map, lang_hooks::types, and UI_SJLJ.
Referenced by lang_dependent_init(), and lto_init_eh().
void init_eh_for_function | ( | void | ) |
References cfun, ggc_cleared_alloc(), and vec_safe_push().
Referenced by allocate_struct_function(), initialize_cfun(), and move_sese_region_to_fn().
Return true if INSN could throw, assuming no REG_EH_REGION note to the contrary.
References CALL_P, cfun, INSN_P, may_trap_p(), and PATTERN().
Referenced by copy_reg_eh_region_note_backward(), copy_reg_eh_region_note_forward(), distribute_notes(), expand_gimple_stmt(), fixup_eh_region_note(), get_eh_region_and_lp_from_rtx(), lra_process_new_insns(), and try_combine().
Return true if INSN cannot throw at all.
References as_a(), rtx_sequence::element(), GET_CODE, get_eh_region_and_lp_from_rtx(), i, insn_nothrow_p(), INSN_P, rtx_sequence::len(), NONJUMP_INSN_P, PATTERN(), and r.
Referenced by can_combine_p(), can_delete_call(), can_split_parallel_of_n_reg_sets(), count_reg_usage(), cse_insn(), deletable_insn_p(), delete_unmarked_insns(), force_move_args_size_note(), insn_live_p(), insn_nothrow_p(), scan_insn(), and try_combine().
References TREE_CODE, type(), and type_to_runtime_map.
Referenced by output_ttype(), and record_type_list().
rtl_opt_pass * make_pass_convert_to_eh_region_ranges | ( | gcc::context * | ctxt | ) |
rtl_opt_pass * make_pass_set_nothrow_function_flags | ( | gcc::context * | ctxt | ) |
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, and GEN_INT.
Referenced by emit_call_1(), and expand_gimple_stmt().
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, INT_MIN, NULL_RTX, and XEXP.
Referenced by emit_libcall_block_1(), and emit_library_call_value_1().
|
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(), as_a(), crtl, emit_insn_after(), GET_CODE, i, LABEL_P, LABEL_PRESERVE_P, call_site_record_d::landing_pad, NOTE_KIND, PATTERN(), PREV_INSN(), vec_safe_length(), and visited.
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(), 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().
|
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, 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().
|
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, 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().
References vec_safe_push().
Referenced by add_action_record().
References vec_safe_push().
Referenced by add_ehspec_entry().
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, eh_region_d::inner, eh_region_d::next_peer, eh_region_d::outer, and remove_eh_handler_splicer().
|
static |
Splice the EH region at PP from the region tree.
References cfun, EH_LANDING_PAD_NR, eh_landing_pad_d::index, eh_region_d::index, eh_region_d::inner, eh_region_d::landing_pads, eh_landing_pad_d::next_lp, eh_region_d::next_peer, NULL, eh_region_d::outer, and eh_landing_pad_d::post_landing_pad.
Referenced by remove_eh_handler(), and remove_unreachable_eh_regions_worker().
void remove_eh_landing_pad | ( | eh_landing_pad | lp | ) |
This section handles removing dead code for flow.
References cfun, EH_LANDING_PAD_NR, eh_landing_pad_d::index, eh_region_d::landing_pads, eh_landing_pad_d::next_lp, NULL, eh_landing_pad_d::post_landing_pad, and eh_landing_pad_d::region.
Referenced by cleanup_empty_eh(), lower_resx(), redirect_eh_edge_1(), and remove_unreachable_handlers().
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, and remove_unreachable_eh_regions_worker().
Referenced by remove_unreachable_handlers(), and remove_unreachable_handlers_no_lp().
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, 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().
References function::eh, table, and eh_status::throw_stmt_table.
Referenced by add_stmt_to_eh_lp_fn().
|
static |
Set TREE_NOTHROW and crtl->all_throwers_are_sibcalls.
References AVAIL_AVAILABLE, CALL_P, cgraph_node::callers, can_throw_external(), cgraph_edge::can_throw_external, crtl, current_function_decl, current_function_name(), dump_file, cgraph_node::get(), cgraph_node::get_availability(), get_insns(), cgraph_edge::next_caller, NEXT_INSN(), cgraph_node::set_nothrow_flag(), SIBLING_CALL_P, and TREE_NOTHROW.
|
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, 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().
|
static |
References assign_stack_local(), cfun, crtl, eh_personality_none, function_needs_eh_personality(), gen_label_rtx(), int_size_in_bytes(), NULL, sjlj_assign_call_site_values(), sjlj_emit_dispatch_table(), sjlj_emit_function_enter(), sjlj_emit_function_exit(), sjlj_fc_type_node, sjlj_lp_call_site_index, sjlj_mark_call_sites(), STACK_SLOT_ALIGNMENT, TYPE_ALIGN, TYPE_MODE, and vec_safe_length().
Referenced by finish_eh_generation().
|
static |
References add_bb_to_loop(), adjust_address, build_case_label(), build_int_cst(), cfun, convert_memory_address, convert_to_mode(), create_artificial_label(), crtl, current_loops, emit_label(), emit_move_insn(), emit_to_new_bb_before(), end_sequence(), expand_builtin_setjmp_receiver(), expand_sjlj_dispatch_table(), force_reg(), forced_labels, gcc_assert, gen_label_rtx(), get_insns(), GET_MODE_SIZE(), loop::header, i, integer_type_node, jump_target_rtx(), LABEL_PRESERVE_P, label_rtx(), eh_landing_pad_d::landing_pad, basic_block_def::loop_father, loop_outer(), make_single_succ_edge(), mark_loop_for_removal(), basic_block_def::next_bb, NULL, eh_landing_pad_d::post_landing_pad, ptr_mode, r, eh_landing_pad_d::region, sjlj_fc_call_site_ofs, sjlj_fc_data_ofs, start_sequence(), targetm, TYPE_MODE, UNKNOWN_LOCATION, vec_safe_iterate(), vec_safe_push(), and vNULL.
Referenced by sjlj_build_landing_pads().
|
static |
Construct the SjLj_Function_Context.
References adjust_address, assemble_external_libcall(), BB_END, build_call_expr(), cfun, const0_rtx, convert_memory_address, copy_addr_to_reg(), crtl, current_function_decl, current_function_funcdef_no, emit_cmp_and_jump_insns(), emit_insn_after(), emit_insn_before(), emit_library_call(), emit_move_insn(), end_sequence(), ENTRY_BLOCK_PTR_FOR_FN, expand_builtin_setjmp_setup(), expand_call(), basic_block_def::flags, get_insns(), get_personality_function(), ggc_strdup, insert_insn_on_edge(), integer_type_node, JUMP_P, LCT_NORMAL, make_tree(), NEXT_INSN(), NOTE_INSN_BASIC_BLOCK_P, NOTE_KIND, NOTE_P, NULL_RTX, plus_constant(), ptr_mode, ptr_type_node, setjmp_fn, single_succ(), single_succ_edge(), sjlj_fc_jbuf_ofs, sjlj_fc_lsda_ofs, sjlj_fc_personality_ofs, split_edge(), start_sequence(), SYMBOL_FLAG_LOCAL, SYMBOL_REF_FLAGS, TYPE_MODE, profile_probability::unlikely(), unwind_sjlj_register_libfunc, and XEXP.
Referenced by sjlj_build_landing_pads().
|
static |
References crtl, emit_insn_after(), emit_library_call(), end_sequence(), get_insns(), LABEL_P, LCT_NORMAL, NEXT_INSN(), start_sequence(), unwind_sjlj_unregister_libfunc, and XEXP.
Referenced by sjlj_build_landing_pads().
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.
Referenced by expand_function_end().
|
static |
Emit code to record the current call-site index before every insn that can throw.
References adjust_address, CALL_P, crtl, emit_insn_before(), emit_move_insn(), end_sequence(), ERT_MUST_NOT_THROW, expand_builtin_update_setjmp_buf(), find_first_parameter_load(), gcc_assert, gen_int_mode(), get_eh_region_and_lp_from_rtx(), get_insns(), GET_MODE, eh_landing_pad_d::index, INSN_P, integer_type_node, LABEL_P, NEXT_INSN(), NOTE_KIND, NOTE_P, NULL, plus_constant(), r, sjlj_fc_call_site_ofs, sjlj_fc_jbuf_ofs, sjlj_lp_call_site_index, start_sequence(), TYPE_MODE, and XEXP.
Referenced by sjlj_build_landing_pads().
|
static |
References call_site_record_d::action, call_site_base, crtl, dw2_asm_output_data_uleb128(), i, INTVAL, call_site_record_d::landing_pad, and vec_safe_length().
Referenced by output_one_function_exception_table().
|
static |
References call_site_record_d::action, crtl, i, INTVAL, call_site_record_d::landing_pad, size_of_uleb128(), and vec_safe_length().
Referenced by output_one_function_exception_table().
|
static |
Switch to the section that should be used for exception tables.
References ASM_PREFERRED_EH_DATA_FORMAT, current_function_decl, data_section, DECL_COMDAT_GROUP, EH_TABLES_CAN_BE_READ_ONLY, exception_section, free(), get_section(), NULL, readonly_data_section, SECTION_LINKONCE, SECTION_WRITE, and switch_to_section().
Referenced by output_function_exception_table().
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().
Referenced by record_new_stack_level().
DEBUG_FUNCTION void verify_eh_tree | ( | struct function * | fun | ) |
Verify invariants on EH datastructures.
References dump_eh_tree(), function::eh, error(), i, eh_landing_pad_d::index, eh_region_d::inner, internal_error(), eh_status::lp_array, eh_landing_pad_d::next_lp, eh_region_d::next_peer, NULL, eh_region_d::outer, r, eh_landing_pad_d::region, eh_status::region_array, eh_status::region_tree, and vec_safe_iterate().
Referenced by duplicate_eh_regions(), and remove_unreachable_handlers().
|
static |
|
static |
Referenced by init_eh(), and sjlj_emit_function_enter().
|
static |
Referenced by init_eh(), sjlj_emit_dispatch_table(), and sjlj_mark_call_sites().
|
static |
Referenced by init_eh(), and sjlj_emit_dispatch_table().
|
static |
Referenced by init_eh(), sjlj_emit_function_enter(), and sjlj_mark_call_sites().
|
static |
Referenced by init_eh(), and sjlj_emit_function_enter().
|
static |
Referenced by init_eh(), and sjlj_emit_function_enter().
|
static |
Describe the SjLj_Function_Context structure.
Referenced by init_eh(), and sjlj_build_landing_pads().
|
static |
Referenced by sjlj_assign_call_site_values(), sjlj_build_landing_pads(), and sjlj_mark_call_sites().
Referenced by add_type_for_runtime(), init_eh(), and lookup_type_for_runtime().