This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[tree-ssa Too many edges in CFG
- From: law at redhat dot com
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 06 May 2003 20:50:06 -0600
- Subject: [tree-ssa Too many edges in CFG
- Reply-to: law at redhat dot com
Andrew & Diego pointed out two goofs in my code to support EH for
the tree-ssa branch. In both cases we're creating unnecessary
edges.
First, we were creating a fall-thru edge for a block which ends
with a volatile call. Opps.
Second, we tried to create a duplicate edge for functions which
receive non-local gotos.
This patch fixes both issues.
* tree-cfg.c (make_exit_edges): Fix handling of blocks which
end with calls.
Index: tree-cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-cfg.c,v
retrieving revision 1.1.4.82
diff -c -3 -p -r1.1.4.82 tree-cfg.c
*** tree-cfg.c 6 May 2003 17:56:12 -0000 1.1.4.82
--- tree-cfg.c 7 May 2003 02:44:58 -0000
*************** make_exit_edges (bb)
*** 1127,1141 ****
/* A CALL_EXPR node here means that the last statement of the block
is a call to a non-returning function or a call that may throw. */
case CALL_EXPR:
! /* Some calls are known not to return, so we just need to make
! an edge from them to the exit block. */
! if (call_expr_flags (last) & (ECF_NORETURN | ECF_LONGJMP))
! make_edge (bb, EXIT_BLOCK_PTR, 0);
if (FUNCTION_RECEIVES_NONLOCAL_GOTO (current_function_decl))
! {
! make_goto_expr_edges (bb);
! make_edge (bb, successor_block (bb), 0);
! }
/* If this statement has reachable exception handlers, then
create abnormal edges to them. */
--- 1127,1137 ----
/* A CALL_EXPR node here means that the last statement of the block
is a call to a non-returning function or a call that may throw. */
case CALL_EXPR:
! /* If this function receives a nonlocal goto, then we need to
! make edges from this call site to all the nonlocal goto
! handlers. */
if (FUNCTION_RECEIVES_NONLOCAL_GOTO (current_function_decl))
! make_goto_expr_edges (bb);
/* If this statement has reachable exception handlers, then
create abnormal edges to them. */
*************** make_exit_edges (bb)
*** 1147,1152 ****
--- 1143,1157 ----
t;
t = TREE_CHAIN (t))
make_edge (bb, first_exec_block (&TREE_VALUE (t)), EDGE_ABNORMAL);
+ }
+
+ /* Some calls are known not to return. For such calls we need to
+ add an edge to the exit block. No fall thru edge is needed
+ as these calls can not return in the normal sense. */
+ if (call_expr_flags (last) & (ECF_NORETURN | ECF_LONGJMP))
+ {
+ make_edge (bb, EXIT_BLOCK_PTR, 0);
+ return;
}
/* Don't forget the fall-thru edge. */