Patchwork PR55191 - ICE in tree-ssa-pre.c due to missing fake edge for an infinite loop

login
register
mail settings
Submitter Steven Bosscher
Date Nov. 5, 2012, 9:59 p.m.
Message ID <CABu31nPCi6+-6AB3bwEn9bXBayg3CgQutwKDOX7=12BHUY+wig@mail.gmail.com>
Download mbox | patch
Permalink /patch/197313/
State New
Headers show

Comments

Steven Bosscher - Nov. 5, 2012, 9:59 p.m.
Hello,

I hadn't expected that cfganal.c's reverse-CFG DFS would actually
depend on the order of the basic blocks. The attached patch fixes that
small oversight...

Bootstrapped&tested on powerpc64-unknown-linux-gnu. OK for trunk?

Ciao!
Steven

        * cfganal.c (connect_infinite_loops_to_exit): Call dfs_deadend
from here.
        (flow_dfs_compute_reverse_execute): Don't call it here.
Jakub Jelinek - Nov. 8, 2012, 10:59 a.m.
On Mon, Nov 05, 2012 at 10:59:45PM +0100, Steven Bosscher wrote:
> I hadn't expected that cfganal.c's reverse-CFG DFS would actually
> depend on the order of the basic blocks. The attached patch fixes that
> small oversight...
> 
> Bootstrapped&tested on powerpc64-unknown-linux-gnu. OK for trunk?
> 
> Ciao!
> Steven
> 

Please put the PR number into the ChangeLog entry.

>         * cfganal.c (connect_infinite_loops_to_exit): Call dfs_deadend
> from here.
>         (flow_dfs_compute_reverse_execute): Don't call it here.

Ok.

> @@ -0,0 +1,14 @@
> +/* PR tree-optimization/55191 */
> +/* { dg-do compile } */
> +/* { dg-options "-O2" } */
> +
> +int a, b;
> +
> +void f(void)
> +{
> +  b = a || b;
> +
> +  for(a = 0; a < 2; a++);
> +  while(1);
> +}
> +

No need for the trailing line.

	Jakub

Patch

Index: cfganal.c
===================================================================
--- cfganal.c   (revision 193141)
+++ cfganal.c   (working copy)
@@ -452,6 +452,7 @@  void
 connect_infinite_loops_to_exit (void)
 {
   basic_block unvisited_block = EXIT_BLOCK_PTR;
+  basic_block deadend_block;
   struct depth_first_search_dsS dfs_ds;

   /* Perform depth-first search in the reverse graph to find nodes
@@ -467,8 +468,9 @@  connect_infinite_loops_to_exit (void)
       if (!unvisited_block)
        break;

-      make_edge (unvisited_block, EXIT_BLOCK_PTR, EDGE_FAKE);
-      flow_dfs_compute_reverse_add_bb (&dfs_ds, unvisited_block);
+      deadend_block = dfs_find_deadend (unvisited_block);
+      make_edge (deadend_block, EXIT_BLOCK_PTR, EDGE_FAKE);
+      flow_dfs_compute_reverse_add_bb (&dfs_ds, deadend_block);
     }

   flow_dfs_compute_reverse_finish (&dfs_ds);
@@ -958,7 +960,7 @@  flow_dfs_compute_reverse_execute (depth_first_sear
   /* Determine if there are unvisited basic blocks.  */
   FOR_BB_BETWEEN (bb, last_unvisited, NULL, prev_bb)
     if (!bitmap_bit_p (data->visited_blocks, bb->index))
-      return dfs_find_deadend (bb);
+      return bb;

   return NULL;
 }
Index: testsuite/gcc.dg/pr55191.c
===================================================================
--- testsuite/gcc.dg/pr55191.c  (revision 0)
+++ testsuite/gcc.dg/pr55191.c  (revision 0)
@@ -0,0 +1,14 @@ 
+/* PR tree-optimization/55191 */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+int a, b;
+
+void f(void)
+{
+  b = a || b;
+
+  for(a = 0; a < 2; a++);
+  while(1);
+}
+