re PR tree-optimization/68625 (Segmentation fault in useless_type_conversion_p)
authorRichard Biener <rguenther@suse.de>
Wed, 2 Dec 2015 09:47:43 +0000 (09:47 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 2 Dec 2015 09:47:43 +0000 (09:47 +0000)
2015-12-02  Richard Biener  <rguenther@suse.de>

PR tree-optimization/68625
* tree-cfgcleanup.c (cleanup_tree_cfg_bb): Do not call
cleanup_control_flow_bb.
(cleanup_tree_cfg_1): First perform cleanup_control_flow_bb
on all BBs, then cleanup_tree_cfg_bb and finally iterate
over the worklist doing both.

* gcc.dg/torture/pr68625.c: New testcase.

From-SVN: r231162

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr68625.c [new file with mode: 0644]
gcc/tree-cfgcleanup.c

index b7e853d061df863e605349c5568f1d63f1c88933..8eaac80b47d78aa371bb6122689412f6c35317e7 100644 (file)
@@ -1,3 +1,12 @@
+2015-12-02  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/68625
+       * tree-cfgcleanup.c (cleanup_tree_cfg_bb): Do not call
+       cleanup_control_flow_bb.
+       (cleanup_tree_cfg_1): First perform cleanup_control_flow_bb
+       on all BBs, then cleanup_tree_cfg_bb and finally iterate
+       over the worklist doing both.
+
 2015-12-02  Richard Sandiford  <richard.sandiford@arm.com>
 
        PR tree-optimization/68432
index 0d686b2d5e8582ea1b56536861afc110a9a8151a..81fcff16945486fdbbb0eb62cf3d7401dc82702c 100644 (file)
@@ -1,3 +1,8 @@
+2015-12-02  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/68625
+       * gcc.dg/torture/pr68625.c: New testcase.
+
 2015-12-02  Richard Sandiford  <richard.sandiford@arm.com>
 
        * gcc.target/i386/pr68432-1.c: New test.
diff --git a/gcc/testsuite/gcc.dg/torture/pr68625.c b/gcc/testsuite/gcc.dg/torture/pr68625.c
new file mode 100644 (file)
index 0000000..47f837a
--- /dev/null
@@ -0,0 +1,51 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-w" } */
+
+int **dp;
+int sg;
+
+void
+z9(void)
+{
+  int pz, oi, vz, yp, zi, hd, pw, gr, w9 = 0, j0 = -1, rb = &w9;
+  int *lr;
+  while (w9 < 1) {
+      lr++;
+      *lr = 1;
+      if (*lr < 1)
+       for (;;)
+         if (pz && *lr) {
+ee:
+             **dp = 0;
+         }
+      pz = zi = vz;
+      if (j0 ^ (vz > 0))
+       continue;
+      **dp = 1;
+      while (**dp)
+       if (++oi) {
+           int mq = dp;
+           j0 = 1;
+           while (pw < 1) {
+               if (++rb && mq)
+                 xq:
+                     hd = sg;
+               ++pw;
+           }
+           sg = 0;
+           while (!sg) {
+               goto ee;
+               while (++yp && gr++) {
+                   int i9, xa;
+                   while (++i9 && ++xa)
+                     fb:
+                         ;
+               }
+           }
+       }
+  }
+  ++vz;
+  if (zi > hd)
+    goto xq;
+  goto fb;
+}
index 9eee7bb8606cc79f279e18ebbde097a0991f896e..40ad5ca33cd4d3867e646c31bc04942ef9b9b1ed 100644 (file)
@@ -614,8 +614,6 @@ fixup_noreturn_call (gimple *stmt)
 static bool
 cleanup_tree_cfg_bb (basic_block bb)
 {
-  bool retval = cleanup_control_flow_bb (bb);
-
   if (tree_forwarder_block_p (bb, false)
       && remove_forwarder_block (bb))
     return true;
@@ -640,7 +638,7 @@ cleanup_tree_cfg_bb (basic_block bb)
        }
     }
 
-  return retval;
+  return false;
 }
 
 /* Iterate the cfg cleanups, while anything changes.  */
@@ -660,8 +658,26 @@ cleanup_tree_cfg_1 (void)
      recording of edge to CASE_LABEL_EXPR.  */
   start_recording_case_labels ();
 
-  /* Start by iterating over all basic blocks.  We cannot use FOR_EACH_BB_FN,
+  /* We cannot use FOR_EACH_BB_FN for the BB iterations below
      since the basic blocks may get removed.  */
+
+  /* Start by iterating over all basic blocks looking for edge removal
+     opportunities.  Do this first because incoming SSA form may be
+     invalid and we want to avoid performing SSA related tasks such
+     as propgating out a PHI node during BB merging in that state.  */
+  n = last_basic_block_for_fn (cfun);
+  for (i = NUM_FIXED_BLOCKS; i < n; i++)
+    {
+      bb = BASIC_BLOCK_FOR_FN (cfun, i);
+      if (bb)
+       retval |= cleanup_control_flow_bb (bb);
+    }
+
+  /* After doing the above SSA form should be valid (or an update SSA
+     should be required).  */
+
+  /* Continue by iterating over all basic blocks looking for BB merging
+     opportunities.  */
   n = last_basic_block_for_fn (cfun);
   for (i = NUM_FIXED_BLOCKS; i < n; i++)
     {
@@ -682,6 +698,7 @@ cleanup_tree_cfg_1 (void)
       if (!bb)
        continue;
 
+      retval |= cleanup_control_flow_bb (bb);
       retval |= cleanup_tree_cfg_bb (bb);
     }