Commit 1ef1bf06 by Andrew MacLeod Committed by Andrew Macleod

except.h (eh_nesting_info): Add new structure defintion.


Tue Aug 10 10:47:42 EDT 1999  Andrew MacLeod  <amacleod@cygnus.com>

	* except.h (eh_nesting_info): Add new structure defintion.
	(init_eh_nesting_info, free_eh_nesting_info): Add function prototypes.
	(reachable_handlers, update_rethrow_references): Add function
	prototypes.
	* rtl.h (struct rtvec_def): Update comments.  REG_EH_RETHROW takes
	a rethrow symbol instead of an integer exception region number.
	* flow.c (Make_edges): Use new exception nesting routines to determine
	which handlers are reachable from a CALL or asynchronous insn.
	Dont add an edge for calls with a REG_EH_REGION of -1 to non-local
	goto receivers.
	(delete_eh_regions): Update rethrow labels, and don't delete
	regions which are the target of a rethrow.
	* except.c (struct func_eh_entry): Add rethrow_ref field, now we can
	avoid overloading the SYMBOL_REF_USED flag.
	(rethrow_symbol_map): Use new rethrow_ref field.
	(rethrow_used): Use new rethrow_ref field.
	(expand_rethrow): REG_EH_RETHROW now has a SYMBOL_REF instead
	of an integer.  Fix formatting.
	(output_exception_table_entry): Use new rethrow_ref field.
	(can_throw): Check for EH_REGION_NOTE before deciding
	whether a CALL can throw or not.
	(scan_region): Call rethrow_used() instead of accessing data structure.
	(update_rethrow_references): New function to make sure only regions
	which are still targets of a rethrow are flagged as such.
	(process_nestinfo): New static function to initialize a handler
	list for a specific region.
	(init_eh_nesting_info): New function to allocate and initialize
	the list of all EH handlers reachable from all regions.
	(reachable_handlers): New function to retrieve the list of handlers
	reachable from a specific region and insn.
	(free_eh_nesting_info): New function to dispose of a list of
	reachable handlers.

From-SVN: r28647
parent a8688bd6
Tue Aug 10 10:47:42 EDT 1999 Andrew MacLeod <amacleod@cygnus.com>
* except.h (eh_nesting_info): Add new structure defintion.
(init_eh_nesting_info, free_eh_nesting_info): Add function prototypes.
(reachable_handlers, update_rethrow_references): Add function
prototypes.
* rtl.h (struct rtvec_def): Update comments. REG_EH_RETHROW takes
a rethrow symbol instead of an integer exception region number.
* flow.c (Make_edges): Use new exception nesting routines to determine
which handlers are reachable from a CALL or asynchronous insn.
Dont add an edge for calls with a REG_EH_REGION of -1 to non-local
goto receivers.
(delete_eh_regions): Update rethrow labels, and don't delete
regions which are the target of a rethrow.
* except.c (struct func_eh_entry): Add rethrow_ref field, now we can
avoid overloading the SYMBOL_REF_USED flag.
(rethrow_symbol_map): Use new rethrow_ref field.
(rethrow_used): Use new rethrow_ref field.
(expand_rethrow): REG_EH_RETHROW now has a SYMBOL_REF instead
of an integer. Fix formatting.
(output_exception_table_entry): Use new rethrow_ref field.
(can_throw): Check for EH_REGION_NOTE before deciding
whether a CALL can throw or not.
(scan_region): Call rethrow_used() instead of accessing data structure.
(update_rethrow_references): New function to make sure only regions
which are still targets of a rethrow are flagged as such.
(process_nestinfo): New static function to initialize a handler
list for a specific region.
(init_eh_nesting_info): New function to allocate and initialize
the list of all EH handlers reachable from all regions.
(reachable_handlers): New function to retrieve the list of handlers
reachable from a specific region and insn.
(free_eh_nesting_info): New function to dispose of a list of
reachable handlers.
Tue Aug 10 10:39:31 EDT 1999 Andrew MacLeod <amacleod@cygnus.com>
* flow.c (split_edge): Set JUMP_LABEL field.
......
......@@ -266,6 +266,11 @@ rtx rethrow_symbol_map PROTO((rtx, rtx (*)(rtx)));
int rethrow_used PROTO((int));
/* Update the rethrow references to reflect rethrows which have been
optimized away. */
void update_rethrow_references PROTO((void));
/* Return the region number a this is the rethrow label for. */
int eh_region_from_symbol PROTO((rtx));
......@@ -278,6 +283,46 @@ struct handler_info *get_first_handler PROTO((int));
int find_all_handler_type_matches PROTO((void ***));
/* The eh_nesting_info structure is used to find a list of valid handlers
for any arbitrary exception region. When init_eh_nesting_info is called,
the information is all pre-calculated and entered in this structure.
REGION_INDEX is a vector over all possible region numbers. Since the
number of regions is typically much smaller than the range of block
numbers, this is a sparse vector and the other data structures are
represented as dense vectors. Indexed with an exception region number, this
returns the index to use in the other data structures to retreive the
correct information.
HANDLERS is an array of vectors which point to handler_info structures.
when indexed, it gives the list of all possible handlers which can
be reached by a throw from this exception region.
NUM_HANDLERS is the equivilent array indicating how many handler
pointers there are in the HANDLERS vector.
OUTER_INDEX indicates which index represents the information for the
outer block. 0 indicates there is no outer context.
REGION_COUNT is the number of regions. */
typedef struct eh_nesting
{
int *region_index;
handler_info ***handlers;
int *num_handlers;
int *outer_index;
int region_count;
} eh_nesting_info;
/* Initialize the eh_nesting_info structure. */
eh_nesting_info *init_eh_nesting_info PROTO((void));
/* Get a list of handlers reachable from a an exception region/insn. */
int reachable_handlers PROTO((int, eh_nesting_info *, rtx,
handler_info ***handlers));
/* Free the eh_nesting_info structure. */
void free_eh_nesting_info PROTO((eh_nesting_info *));
extern void init_eh PROTO((void));
/* Initialization for the per-function EH data. */
......
......@@ -867,6 +867,7 @@ make_edges (label_value_list, bb_eh_end)
rtx *bb_eh_end;
{
int i;
eh_nesting_info *eh_nest_info = init_eh_nesting_info ();
/* Assume no computed jump; revise as we create edges. */
current_function_has_computed_jump = 0;
......@@ -976,41 +977,19 @@ make_edges (label_value_list, bb_eh_end)
if (code == CALL_INSN || asynchronous_exceptions)
{
int is_call = (code == CALL_INSN ? EDGE_ABNORMAL_CALL : 0);
handler_info *ptr;
handler_info **handler_list;
int eh_region = -1;
int num;
/* Use REG_EH_RETHROW and REG_EH_REGION if available. */
/* ??? REG_EH_REGION is not generated presently. Is it
inteded that there be multiple notes for the regions?
or is my eh_list collection redundant with handler linking? */
if (eh_list)
eh_region = NOTE_BLOCK_NUMBER (XEXP (eh_list, 0));
x = find_reg_note (insn, REG_EH_RETHROW, 0);
if (!x)
x = find_reg_note (insn, REG_EH_REGION, 0);
if (x)
num = reachable_handlers (eh_region, eh_nest_info,
insn, &handler_list);
for ( ; num > 0; num--)
{
if (XINT (XEXP (x, 0), 0) > 0)
{
ptr = get_first_handler (XINT (XEXP (x, 0), 0));
while (ptr)
{
make_label_edge (bb, ptr->handler_label,
EDGE_ABNORMAL | EDGE_EH | is_call);
ptr = ptr->next;
}
}
}
else
{
for (x = eh_list; x; x = XEXP (x, 1))
{
ptr = get_first_handler (NOTE_BLOCK_NUMBER (XEXP (x, 0)));
while (ptr)
{
make_label_edge (bb, ptr->handler_label,
EDGE_ABNORMAL | EDGE_EH | is_call);
ptr = ptr->next;
}
}
make_label_edge (bb, handler_list[num - 1]->handler_label,
EDGE_ABNORMAL | EDGE_EH | is_call);
}
if (code == CALL_INSN && nonlocal_goto_handler_labels)
......@@ -1022,10 +1001,13 @@ make_edges (label_value_list, bb_eh_end)
gotos do not have their addresses taken, then only calls to
those functions or to other nested functions that use them
could possibly do nonlocal gotos. */
for (x = nonlocal_goto_handler_labels; x ; x = XEXP (x, 1))
make_label_edge (bb, XEXP (x, 0),
EDGE_ABNORMAL | EDGE_ABNORMAL_CALL);
/* We do know that a REG_EH_REGION note with a value less
than 0 is guaranteed not to perform a non-local goto. */
rtx note = find_reg_note (insn, REG_EH_REGION, NULL_RTX);
if (!note || XINT (XEXP (note, 0), 0) >= 0)
for (x = nonlocal_goto_handler_labels; x ; x = XEXP (x, 1))
make_label_edge (bb, XEXP (x, 0),
EDGE_ABNORMAL | EDGE_ABNORMAL_CALL);
}
}
......@@ -1050,6 +1032,7 @@ make_edges (label_value_list, bb_eh_end)
make_edge (bb, BASIC_BLOCK (i + 1), EDGE_FALLTHRU);
}
}
free_eh_nesting_info (eh_nest_info);
}
/* Create an edge between two basic blocks. FLAGS are auxiliary information
......@@ -1615,6 +1598,8 @@ delete_eh_regions ()
{
rtx insn;
update_rethrow_references ();
for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
if (GET_CODE (insn) == NOTE)
{
......@@ -1622,8 +1607,9 @@ delete_eh_regions ()
(NOTE_LINE_NUMBER (insn) == NOTE_INSN_EH_REGION_END))
{
int num = CODE_LABEL_NUMBER (insn);
/* A NULL handler indicates a region is no longer needed */
if (get_first_handler (num) == NULL)
/* A NULL handler indicates a region is no longer needed,
as long as it isn't the target of a rethrow. */
if (get_first_handler (num) == NULL && ! rethrow_used (num))
{
NOTE_LINE_NUMBER (insn) = NOTE_INSN_DELETED;
NOTE_SOURCE_FILE (insn) = 0;
......
......@@ -344,13 +344,13 @@ typedef struct rtvec_def{
rtx is used instead of intuition. */
/* REG_EH_REGION is used to indicate what exception region an INSN
belongs in. This can be used to indicate what region a call may throw
to. A REGION of 0 indicates that a call cannot throw at all.
A REGION of -1 indicates that it cannot throw, nor will it execute
to. a REGION of 0 indicates that a call cannot throw at all.
a REGION of -1 indicates that it cannot throw, nor will it execute
a non-local goto.
REG_EH_RETHROW is used to indicate what that a call is actually a
call to rethrow, and specifies which region the rethrow is targetting.
This provides a way to generate the non standard flow edges required
for a rethrow. */
REG_EH_RETHROW is used to indicate that a call is actually a
call to rethrow, and specifies the rethrow symbol for the region
the rethrow is targetting. This provides a way to generate the
non standard flow edges required for a rethrow. */
#define REG_NOTES(INSN) ((INSN)->fld[6].rtx)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment