This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] tree-cfg.c: Make find_taken_edge_cond_expr safer.


Hi,

Attached is a patch to make find_taken_edge_cond_expr safer by
aborting if COND_EXPR has two identical edges.

tree_redirect_edge_and_branch (and
tree_try_redirect_by_replacing_jump) is supposed to take care of
removing COND_EXPR should its two arms end up going to the same basic
block during some optimization.

Tested on i686-pc-linux-gnu.  OK to apply?

p.s.
Actually, tree_verify_flow_info checks these things extensively, so I
don't mind even removing the "if" statement (or gcc_assert)
altogether.

Kazu Hirata

2004-11-03  Kazu Hirata  <kazu@cs.umass.edu>

	* tree-cfg.c (find_taken_edge_cond_expr): Abort if COND_EXPR
	has two identical edges.

Index: tree-cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-cfg.c,v
retrieving revision 2.98
diff -u -d -p -r2.98 tree-cfg.c
--- tree-cfg.c	3 Nov 2004 01:40:56 -0000	2.98
+++ tree-cfg.c	3 Nov 2004 01:45:08 -0000
@@ -1986,10 +1986,8 @@ find_taken_edge_cond_expr (basic_block b
 
   extract_true_false_edges_from_block (bb, &true_edge, &false_edge);
 
-  /* If both edges of the branch lead to the same basic block, it doesn't
-     matter which edge is taken.  */
-  if (true_edge->dest == false_edge->dest)
-    return true_edge;
+  /* We never create multiple copies of the same edge.  */
+  gcc_assert (true_edge->dest != false_edge->dest);
 
   /* Otherwise, try to determine which branch of the if() will be taken.
      If VAL is a constant but it can't be reduced to a 0 or a 1, then


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]