This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Fix handling of calls wrt EH
> On Fri, May 13, 2005 at 05:26:54AM +0200, Jan Hubicka wrote:
> > + /* ??? For the benefit of calls.c, converting all this to rtl,
> > + we need to record the call expression, not just the outer
> > + modify statement. */
> > + if ((TREE_CODE (t) == MODIFY_EXPR
> > + || TREE_CODE (t) == RETURN_EXPR)
> > + && (t = get_call_expr_in (t)))
> > + add_stmt_to_eh_region_fn (ifun, t, num);
>
> If we're going to do this, I think we should rearrange add_stmt_eh_region
> and record_stmt_eh_region (and their callers) such that we only do this in
> one place.
>
> And did you really need to check RETURN_EXPR? We're not testing for that
> in lower_eh_constructs_1. Either your test is unnecessary or we've got a
> latent bug.
I guess it is not neccesary, I just copied what the old code did without
much thinking abou it ;(
Does the attached patch seem to make more sense (I just started testing
it)
I guess I can also add verify_flow_info check that call_expr is in sync
(I have few extra EH checking bits so I will push this out together if
we decide to walk this way)
Honza
2005-05-13 Jan Hubicka <jh@suse.cz>
* tree-eh.c (record_stmt_eh_region): Use add_stmt_to_eh_region.
(add_stmt_to_eh_region_fn): Mark CALL_EXPR inside MODIFY_EXPR too.
(remove_stmt_from_eh_region_fn): Unmark CALL_EXPR inside MODIFY_EXPR
too.
(lower_eh_constructs_1): Kill the CALL_EXPR hack here.
(lower_eh_constructs): Don't care initializing throw_stmt_table.
Index: tree-eh.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-eh.c,v
retrieving revision 2.35
diff -c -3 -p -r2.35 tree-eh.c
*** tree-eh.c 12 May 2005 19:29:21 -0000 2.35
--- tree-eh.c 13 May 2005 19:04:53 -0000
*************** struct_ptr_hash (const void *a)
*** 84,102 ****
static void
record_stmt_eh_region (struct eh_region *region, tree t)
{
- struct throw_stmt_node *n;
- void **slot;
-
if (!region)
return;
! n = ggc_alloc (sizeof (*n));
! n->stmt = t;
! n->region_nr = get_eh_region_number (region);
!
! slot = htab_find_slot (get_eh_throw_stmt_table (cfun), n, INSERT);
! gcc_assert (!*slot);
! *slot = n;
}
void
--- 84,93 ----
static void
record_stmt_eh_region (struct eh_region *region, tree t)
{
if (!region)
return;
! add_stmt_to_eh_region (t, get_eh_region_number (region));
}
void
*************** add_stmt_to_eh_region_fn (struct functio
*** 120,125 ****
--- 111,122 ----
slot = htab_find_slot (get_eh_throw_stmt_table (ifun), n, INSERT);
gcc_assert (!*slot);
*slot = n;
+ /* ??? For the benefit of calls.c, converting all this to rtl,
+ we need to record the call expression, not just the outer
+ modify statement. */
+ if (TREE_CODE (t) == MODIFY_EXPR
+ && (t = get_call_expr_in (t)))
+ add_stmt_to_eh_region_fn (ifun, t, num);
}
void
*************** remove_stmt_from_eh_region_fn (struct fu
*** 143,148 ****
--- 140,152 ----
if (slot)
{
htab_clear_slot (get_eh_throw_stmt_table (ifun), slot);
+ /* ??? For the benefit of calls.c, converting all this to rtl,
+ we need to record the call expression, not just the outer
+ modify statement. */
+ if ((TREE_CODE (t) == MODIFY_EXPR
+ || TREE_CODE (t) == RETURN_EXPR)
+ && (t = get_call_expr_in (t)))
+ remove_stmt_from_eh_region_fn (ifun, t);
return true;
}
else
*************** lower_eh_constructs_1 (struct leh_state
*** 1618,1634 ****
/* Look for things that can throw exceptions, and record them. */
if (state->cur_region && tree_could_throw_p (t))
{
- tree op;
-
record_stmt_eh_region (state->cur_region, t);
note_eh_region_may_contain_throw (state->cur_region);
-
- /* ??? For the benefit of calls.c, converting all this to rtl,
- we need to record the call expression, not just the outer
- modify statement. */
- op = get_call_expr_in (t);
- if (op)
- record_stmt_eh_region (state->cur_region, op);
}
break;
--- 1622,1629 ----
*************** lower_eh_constructs (void)
*** 1689,1697 ****
tree *tp = &DECL_SAVED_TREE (current_function_decl);
finally_tree = htab_create (31, struct_ptr_hash, struct_ptr_eq, free);
- set_eh_throw_stmt_table (cfun, htab_create_ggc (31, struct_ptr_hash,
- struct_ptr_eq,
- ggc_free));
collect_finally_tree (*tp, NULL);
--- 1684,1689 ----