GCC Middle and Back End API Reference
|
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "tm.h"
#include "rtl.h"
#include "tree.h"
#include "flags.h"
#include "function.h"
#include "expr.h"
#include "libfuncs.h"
#include "insn-config.h"
#include "except.h"
#include "hard-reg-set.h"
#include "basic-block.h"
#include "output.h"
#include "dwarf2asm.h"
#include "dwarf2out.h"
#include "dwarf2.h"
#include "toplev.h"
#include "hash-table.h"
#include "intl.h"
#include "ggc.h"
#include "tm_p.h"
#include "target.h"
#include "common/common-target.h"
#include "langhooks.h"
#include "cgraph.h"
#include "diagnostic.h"
#include "tree-pretty-print.h"
#include "tree-pass.h"
#include "gimple.h"
#include "cfgloop.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 | EH_RETURN_DATA_REGNO(N) INVALID_REGNUM |
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 htab_t | type_to_runtime_map |
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 EH_RETURN_DATA_REGNO | ( | N | ) | INVALID_REGNUM |
Implements exception handling. Copyright (C) 1989-2013 Free Software Foundation, Inc. Contributed by Mike Stump mrs@c. ygnu s.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, WITH_CLEANUP_EXPR, CLEANUP_POINT_EXPR, CATCH_EXPR, and EH_FILTER_EXPR.
During initial gimplification (gimplify.c) these are lowered to the GIMPLE_TRY, GIMPLE_CATCH, 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.c) 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.c), 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.c), 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.c), 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.c), 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.c) 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.c) emits the required unwind data. Provide defaults for stuff that may not be defined when using sjlj exceptions.
typedef hash_table<ehspec_hasher> ehspec_hash_type |
|
static |
The filter value goes in untouched. The link to the next record is a "self-relative" byte offset, or zero to indicate that there is no next record. So convert the absolute 1 based indices we've been carrying around into a displacement.
Referenced by expand_eh_return().
|
static |
Referenced by collect_one_action_chain().
|
static |
|
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.
Filter value is a -1 based byte index into a uleb128 buffer.
Generate a 0 terminated list of filter values.
Look up each type in the list and encode its filter value as a uleb128.
|
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.
Filter value is a 1 based table index.
References cfun, ttypes_filter::filter, push_uleb128(), ttypes_filter::t, targetm, TREE_CHAIN, TREE_VALUE, vec_safe_length(), and vec_safe_push().
void add_type_for_runtime | ( | ) |
If TYPE is NOP_EXPR, it means that it already is a runtime type.
Referenced by 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.
Whatever type_list is (NULL or true list), we build a list of filters for the region.
Get a filter value for each of the types caught and store them in the region's dedicated list.
Get a filter value for the NULL list also since it will need an action record anyway.
bool can_nonlocal_goto | ( | ) |
Return true if INSN can perform a non-local goto. ??? This test is here in this file because it (ab)uses REG_EH_REGION.
bool can_throw_external | ( | ) |
Return true if INSN throws and escapes from the current function.
If we can't throw, we obviously can't throw external.
If we have an internal landing pad, then we're not external.
If we're not within an EH region, then we are external.
The only thing that ought to be left is MUST_NOT_THROW regions, which don't always have landing pads.
References CALL_P, crtl, and SIBLING_CALL_P.
Referenced by get_eh_region_and_lp_from_rtx().
bool can_throw_internal | ( | ) |
Return true if INSN throws and is caught by something in this function.
References crtl.
Referenced by process_bb_node_lives().
|
static |
Referenced by collect_one_action_chain(), and expand_eh_return().
|
static |
If we've reached the top of the region chain, then we have no actions, and require no landing pad.
A cleanup adds a zero filter to the beginning of the chain, but there are special cases to look out for. If there are *only* cleanups along a path, then it compresses to a zero action. Further, if there are multiple cleanups along a path, we only need to represent one of them, as that is enough to trigger entry to the landing pad at runtime.
Process the associated catch regions in reverse order. If there's a catch-all handler, then we don't need to search outer regions. Use a magic -3 value to record that we haven't done the outer search.
Retrieve the filter from the head of the filter list where we have stored it (see assign_filter_values).
Once the outer search is done, trigger an action record for each filter we have.
If there is no next action, terminate the chain.
If all outer actions are cleanups or must_not_throw, we'll have no action record for it, since we had wanted to encode these states in the call-site record directly. Add a cleanup action to the chain to catch these.
An exception specification adds its filter to the beginning of the chain.
If there is no next action, terminate the chain.
If all outer actions are cleanups or must_not_throw, we'll have no action record for it, since we had wanted to encode these states in the call-site record directly. Add a cleanup action to the chain to catch these.
A must-not-throw region with no inner handlers or cleanups requires no call-site entry. Note that this differs from the no handler or cleanup case in that we do require an lsda to be generated. Return a magic -2 value to record this.
References add_call_site(), call_site_base, collect_one_action_chain(), hash_table< Descriptor, Allocator >::create(), crtl, emit_note_after(), emit_note_before(), 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, NULL_RTX, PATTERN, vec_alloc(), and XVECEXP.
|
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.
Existence of catch handlers, or must-not-throw regions implies that an lsda is needed (even if empty).
Delay creation of region notes for no-action regions until we're sure that an lsda will be required.
Differing actions or landing pads implies a change in call-site info, which implies some EH_REGION note should be emitted.
If there is a queued no-action region in the other section with hot/cold partitioning, emit it now.
If we'd not seen a previous action (-3) or the previous action was must-not-throw (-2), then we do not need an end note.
If we delayed the creation of the begin, do it now.
If the new action is must-not-throw, then no region notes are created.
Force closing of current EH region before section switch and opening a new one afterwards.
void copy_reg_eh_region_note_backward | ( | ) |
Likewise, but iterate backward.
void copy_reg_eh_region_note_forward | ( | ) |
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 get_eh_region_and_lp_from_rtx().
bool current_function_has_exception_handlers | ( | void | ) |
Returns true if the current function has exception handling regions.
References duplicate_eh_regions_data::eh_map, gen_eh_region(), pointer_map_insert(), and eh_region_d::type.
DEBUG_FUNCTION void debug_eh_tree | ( | ) |
Dump the EH tree for FN on stderr.
void dump_eh_tree | ( | ) |
Dump EH information to OUT.
If there are sub-regions, process them.
If there are peers, process them.
Otherwise, step back up the tree to the next peer.
|
read |
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.
Copy all the regions in the subtree.
References duplicate_eh_regions_1(), and eh_region_d::next_peer.
|
static |
We should be doing all our region duplication before and during inlining, which is before filter lists are created.
Don't bother copying unused landing pads. Make sure to preserve the original use of __cxa_end_cleanup.
References eh_region_d::eh_region_u::eh_try, eh_catch_d::filter_list, eh_region_d::eh_region_u::eh_region_u_try::first_catch, gcc_assert, gen_eh_region_catch(), eh_catch_d::label, duplicate_eh_regions_data::label_map, duplicate_eh_regions_data::label_map_data, eh_catch_d::next_catch, NULL, eh_catch_d::type_list, and eh_region_d::u.
Referenced by duplicate_eh_regions().
|
static |
Expand the extra code needed at landing pads for dwarf2 unwinding.
If we're going to partition blocks, we need to be able to add new landing pads later, which means that we need to hold on to the post-landing-pad block. Prevent it from being merged away. We'll remove this bit after partitioning.
If we created a pre-header block, add the new block to the outer loop, otherwise to the loop itself.
|
static |
|
static |
??? Perhaps use insn length scaling if the assembler supports generic arithmetic.
??? Perhaps use attr_length to choose data1 or data2 instead of data4 if the function is small enough.
References expand_expr(), EXPAND_INITIALIZER, gcc_assert, lookup_type_for_runtime(), NULL_RTX, STRIP_NOPS, TREE_CODE, TREE_OPERAND, TREE_PUBLIC, and TYPE_P.
|
static |
|
static |
References DECL_ONE_ONLY, get_section(), and SECTION_LINKONCE.
Return the region that is outer to both REGION_A and REGION_B in IFUN.
Referenced by move_stmt_op().
|
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.
If there happens to be a fallthru edge (possibly created by cleanup_cfg call), we don't want it to go into newly created landing pad or other EH construct.
References targetm.
|
static |
Various hooks for unwind library. Expand the EH support builtin functions: __builtin_eh_pointer and __builtin_eh_filter.
??? We shouldn't have been able to delete a eh region without deleting all the code that depended on it.
rtx expand_builtin_eh_copy_values | ( | ) |
Copy the exc_ptr and filter values from one landing pad's registers to another. This is used to inline the resx statement.
rtx expand_builtin_eh_filter | ( | ) |
Expand to the filter value from the given eh region.
rtx expand_builtin_eh_pointer | ( | ) |
Expand to the exc_ptr value from the given eh region.
Set up the epilogue with the magic bits we'll need to return to the exception handler.
rtx expand_builtin_eh_return_data_regno | ( | ) |
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.
rtx expand_builtin_extend_pointer | ( | ) |
Convert a ptr_mode address ADDR_TREE to a Pmode address controlled by POINTERS_EXTEND_UNSIGNED and return it.
The previous EH code did an unsigned extend by default, so we do this also for consistency.
rtx expand_builtin_extract_return_addr | ( | ) |
Given a value extracted from the return address register or stack slot, return the actual address encoded in that value.
First mask out any unwanted bits.
Then adjust to find the real return address.
rtx expand_builtin_frob_return_addr | ( | ) |
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 crtl, action_record::filter, action_record::next, action_record::offset, and push_sleb128().
void expand_builtin_unwind_init | ( | void | ) |
Do any necessary initialization to access arbitrary stack frames. On the SPARC, this means flushing the register windows.
Set this so all the registers get saved in our frame; we need to be able to copy the saved values for any registers from frames we unwind.
void expand_dw2_landing_pad_for_region | ( | ) |
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.
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 add_action_record(), collect_one_action_chain(), eh_region_d::eh_region_u::eh_try, eh_catch_d::filter_list, eh_region_d::eh_region_u::eh_region_u_try::last_catch, eh_region_d::outer, eh_catch_d::prev_catch, TREE_CHAIN, TREE_INT_CST_LOW, TREE_VALUE, eh_catch_d::type_list, and eh_region_d::u.
void finish_eh_generation | ( | void | ) |
After initial rtl generation, call back to finish generating exception support code.
Construct the landing pads.
Kludge for Alpha (see alpha_gp_save_rtx).
Redirect all EH edges from the post_landing_pad to the landing pad.
We should not have generated any new throwing insns during this pass, and we should not have lost any EH edges, so we only need to handle two cases here: (1) reachable handler and an existing edge to post-landing-pad, (2) no reachable handler and no edge.
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 add_reg_note(), find_reg_note(), insn_could_throw_p(), INSN_P, last, NEXT_INSN, NULL_RTX, and XEXP.
enum eh_personality_kind function_needs_eh_personality | ( | ) |
Determine if the function needs an EH personality function.
Can do with any personality including the generic C one.
Always needs a EH personality function. The generic C personality doesn't handle these even for empty type lists.
Always needs a EH personality function. The language may specify what abort routine that must be used, e.g. std::terminate.
|
static |
Nothing to do for SJLJ exceptions or if no regions created.
eh_landing_pad gen_eh_landing_pad | ( | ) |
Referenced by do_return_redirection(), lower_eh_constructs(), and record_stmt_eh_region().
|
static |
Routines to generate the exception tree somewhat directly. These are used from tree-eh.c when processing exception related nodes during tree optimization.
Insert a new blank region as a leaf in the tree.
Copy the language's notion of whether to use __cxa_end_cleanup.
Referenced by current_function_has_exception_handlers().
eh_region gen_eh_region_allowed | ( | ) |
eh_catch gen_eh_region_catch | ( | ) |
Ensure to always end up with a type list to normalize further processing, then register each type against the runtime types map.
Referenced by duplicate_eh_regions_1().
eh_region gen_eh_region_cleanup | ( | ) |
eh_region gen_eh_region_must_not_throw | ( | ) |
eh_landing_pad get_eh_landing_pad_from_number | ( | ) |
Referenced by lower_eh_constructs().
eh_landing_pad get_eh_landing_pad_from_number_fn | ( | ) |
eh_landing_pad get_eh_landing_pad_from_rtx | ( | ) |
Return the landing pad to which INSN may go, or NULL if it does not have a reachable landing pad within this function.
|
static |
Extract all EH information from INSN. Return true if the insn was marked NOTHROW.
References can_throw_external(), PATTERN, XVECEXP, and XVECLEN.
Referenced by collect_one_action_chain(), copy_reg_eh_region_note_forward(), and sjlj_assign_call_site_values().
eh_region get_eh_region_from_lp_number | ( | ) |
References duplicate_eh_regions_data::eh_map, duplicate_eh_regions_data::label_map, and duplicate_eh_regions_data::label_map_data.
Referenced by mark_reachable_handlers().
eh_region get_eh_region_from_lp_number_fn | ( | ) |
References cfun.
Referenced by move_stmt_op().
eh_region get_eh_region_from_number | ( | ) |
eh_region get_eh_region_from_number_fn | ( | ) |
eh_region get_eh_region_from_rtx | ( | ) |
Return the region to which INSN may go, or NULL if it does not have a reachable region within this function.
References CALL_P, find_reg_note(), INT_MIN, INTVAL, nonlocal_goto_handler_labels, NULL_RTX, and XEXP.
htab_t get_eh_throw_stmt_table | ( | ) |
void init_eh | ( | void | ) |
In except.c. Initialize exception handling. This is used by the Ada and LTO front ends to initialize EH "on demand". See lto-streamer-in.c and ada/gcc-interface/misc.c.
Create the SjLj_Function_Context structure. This should match the definition in unwind-sjlj.c.
builtin_setjmp takes a pointer to 5 words.
Cache the interesting field offsets so that we have easy access from rtl.
References targetm.
void init_eh_for_function | ( | void | ) |
Make sure zero'th entries are used.
References eh_region_d::inner, eh_region_d::next_peer, eh_region_d::outer, eh_region_d::type, and type().
bool insn_could_throw_p | ( | ) |
Return true if INSN could throw, assuming no REG_EH_REGION note to the contrary.
Referenced by for_each_eh_label().
bool insn_nothrow_p | ( | ) |
Return true if INSN cannot throw at all.
Referenced by force_move_args_size_note(), and set_nonzero_bits_and_sign_copies().
tree lookup_type_for_runtime | ( | ) |
If TYPE is NOP_EXPR, it means that it already is a runtime type.
We should have always inserted the data earlier.
References ttypes_filter_hasher::equal(), and ttypes_filter_hasher::hash().
Referenced by dw2_output_call_site_table().
rtl_opt_pass* make_pass_convert_to_eh_region_ranges | ( | ) |
rtl_opt_pass* make_pass_set_nothrow_function_flags | ( | ) |
References constm1_rtx, and error().
void make_reg_eh_region_note | ( | ) |
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.
void make_reg_eh_region_note_nothrow_nononlocal | ( | ) |
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.
void output_function_exception_table | ( | ) |
Not all functions need anything.
If the target wants a label to begin the table, emit it here.
|
static |
Indicate the format of the @TType entries.
The LSDA header.
Indicate the format of the landing pad start pointer. An omitted field implies @LPStart == @Start.
Currently we always put @LPStart == @Start. This field would be most useful in moving the landing pads completely out of line to another section, but it could also be used to minimize the size of uleb128 landing pad offsets.
@LPStart pointer would go here.
A pc-relative 4-byte displacement to the @TType data.
Ug. Alignment queers things.
Indicate the format of the call-site offsets.
??? Decode and interpret the data for flag_debug_asm.
??? Decode and interpret the data for flag_debug_asm.
References targetm.
|
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.
FIXME lto. pass_ipa_free_lang_data changes all types to runtime types so TYPE should already be a runtime type reference. When pass_ipa_free_lang data is made a default pass, we can then remove the call to lookup_type_for_runtime below.
Let cgraph know that the rtti decl is used. Not all of the paths below go through assemble_integer, which would take care of this for us.
Allow the target to override the type table entry format.
Referenced by expand_builtin_frob_return_addr().
|
static |
References ASM_PREFERRED_EH_DATA_FORMAT, EH_TABLES_CAN_BE_READ_ONLY, and SECTION_WRITE.
Referenced by add_ttypes_entry().
|
static |
void remove_eh_handler | ( | ) |
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 add_reg_note(), const0_rtx, ECF_NOTHROW, and GEN_INT.
|
static |
Splice the EH region at PP from the region tree.
References cfun, and remove_unreachable_eh_regions_worker().
Referenced by remove_eh_landing_pad().
void remove_eh_landing_pad | ( | ) |
This section handles removing dead code for flow.
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 lower_eh_constructs().
void remove_unreachable_eh_regions | ( | ) |
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 CALL_P, cfun, INSN_P, may_trap_p(), and PATTERN.
|
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 add_reg_note(), find_reg_note(), GEN_INT, INT_MIN, NULL_RTX, and XEXP.
Referenced by remove_eh_handler_splicer(), and remove_eh_landing_pad().
void set_eh_throw_stmt_table | ( | ) |
|
static |
Set TREE_NOTHROW and crtl->all_throwers_are_sibcalls.
Assume crtl->all_throwers_are_sibcalls until we encounter something that can throw an exception. We specifically exempt CALL_INSNs that are SIBLING_CALL_P, as these are really jumps, and can't throw. Most CALL_INSNs are not SIBLING_CALL_P, so this is optimistic.
If we don't know that this implementation of the function will actually be used, then we must not set TREE_NOTHROW, since callers must not assume that this function does not throw.
|
static |
Process all active landing pads. Assign each one a compact dispatch index, and a call-site index.
First: build the action table.
Next: assign call-site values. If dwarf2 terms, this would be the region number assigned by convert_to_eh_region_ranges, but handles no-action and must-not-throw differently.
Map must-not-throw to otherwise unused call-site index 0.
Map no-action to otherwise unused call-site index -1.
Otherwise, look it up in the table.
References adjust_address, CALL_P, crtl, emit_move_insn(), end_sequence(), ERT_MUST_NOT_THROW, 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, NULL, NULL_RTX, sjlj_fc_call_site_ofs, start_sequence(), eh_region_d::type, and TYPE_MODE.
|
static |
If we do not have any landing pads, we may still need to register a personality routine and (empty) LSDA to handle must-not-throw regions.
|
static |
The caller of expand_builtin_setjmp_receiver is responsible for making sure that the label doesn't vanish. The only other caller is the expander for __builtin_setjmp_receiver, which places this label on the nonlocal_goto_label list. Since we're modeling these CFG edges more exactly, we can use the forced_labels list instead.
Load up exc_ptr and filter values from the function context.
Jump to one of the directly reachable regions.
If there's exactly one call site in the function, don't bother generating a switch statement.
If we created a pre-header block, add the new block to the outer loop, otherwise to the loop itself.
??? For multiple dispatches we will end up with edges from the loop tree root into this loop, making it a multiple-entry loop. Discard all affected loops.
If we created a pre-header block, add the new block to the outer loop, otherwise to the loop itself.
We are not wiring up edges here, but as the dispatcher call is at function begin simply associate the block with the outermost (non-)loop.
|
static |
Construct the SjLj_Function_Context.
We're storing this libcall's address into memory instead of calling it directly. Thus, we must call assemble_external_libcall here, as we can not depend on emit_library_call to do it for us.
??? Instead of doing this at the beginning of the function, do this in a block that is at loop level 0 and dominates all can_throw_internal instructions.
References NOTE_INSN_BASIC_BLOCK_P, and NOTE_KIND.
|
static |
??? Really this can be done in any block at loop level 0 that post-dominates all can_throw_internal instructions. This is the last possible moment.
void sjlj_emit_function_exit_after | ( | ) |
Call back from expand_function_end to know where we should put the call to unwind_sjlj_unregister_libfunc if needed.
|
static |
Emit code to record the current call-site index before every insn that can throw.
Reset value tracking at extended basic block boundaries.
Calls (and trapping insns) without notes are outside any exception handling region in this function. Mark them as no action.
Don't separate a call from it's argument loads.
|
static |
|
static |
|
static |
Switch to the section that should be used for exception tables.
Compute the section and cache it into exception_section, unless it depends on the function name.
|
static |
|
static |
References lang_hooks::eh_runtime_type, NULL_TREE, and tree_cons.
|
static |
|
static |
DEBUG_FUNCTION void verify_eh_tree | ( | ) |
Verify invariants on EH datastructures.
|
static |
Referenced by collect_one_action_chain().
|
static |
Referenced by sjlj_assign_call_site_values().
|
static |
|
static |
|
static |
|
static |
|
static |
Describe the SjLj_Function_Context structure.
|
static |
|
static |