[PATCH] Avoid inserting DEBUG_STMTs after maybe throwing stmts
Jakub Jelinek
jakub@redhat.com
Thu Jan 21 16:23:00 GMT 2010
On Thu, Jan 21, 2010 at 05:17:28PM +0100, Jan Hubicka wrote:
> > --- gcc/tree-into-ssa.c.jj 2010-01-21 09:58:38.000000000 +0100
> > +++ gcc/tree-into-ssa.c 2010-01-21 12:25:22.000000000 +0100
> > @@ -1968,7 +1968,25 @@ maybe_register_def (def_operand_p def_p,
> > if (tracked_var)
> > {
> > gimple note = gimple_build_debug_bind (tracked_var, def, stmt);
> > - gsi_insert_after (&gsi, note, GSI_SAME_STMT);
> > + if (gsi_one_before_end_p (gsi) && stmt_ends_bb_p (stmt))
> > + {
> > + basic_block bb = gsi_bb (gsi);
> > + edge_iterator ei;
> > + edge e, ef = NULL;
> > + FOR_EACH_EDGE (e, ei, bb->succs)
> > + if (!(e->flags & EDGE_EH))
> > + {
> > + gcc_assert (!ef);
> > + ef = e;
> > + }
>
> I would probably add an assert that there is no other non-EH edge. It
> makes sense to support i.e. -fnon-call-exceptions fp conditionals that
> might throw.
Add or remove? The code has assert that there is at most one non-EH edge
(that's the gcc_assert (!ef); in the loop) and that there is at least one
(below the loop).
Alternatively, we could just avoid all the asserts, instead not add the
DEBUG_STMT at all in cases we are not prepared to handle:
if (gsi_one_before_end_p (gsi) && stmt_ends_bb_p (stmt))
{
basic_block bb = gsi_bb (gsi);
edge_iterator ei;
edge e, ef = NULL;
FOR_EACH_EDGE (e, ei, bb->succs)
if (!(e->flags & EDGE_EH))
{
if (ef)
{
ef = NULL;
break;
}
ef = e;
}
if (ef
&& single_pred_p (ef->dest)
&& !phi_nodes (ef->dest)
&& ef->dest != EXIT_BLOCK_PTR)
gsi_insert_on_edge_immediate (ef, note);
}
else
gsi_insert_after (&gsi, note, GSI_SAME_STMT);
Jakub
More information about the Gcc-patches
mailing list