cleanup_tree_cfg can make it necessary to update SSA form.  The following
reflects that in execute_cleanup_cfg_post_optimizing (other callers
look safe as they are embedded in more complex passes updating SSA form
anyways).

Bootstrap and regtest pending on x86_64-unknown-linux-gnu.

Richard.

2012-01-30  Richard Guenther  <rguent...@suse.de>

        PR tree-optimization/52045
        * tree-optimize.c (execute_cleanup_cfg_post_optimizing): Update
        SSA form if cfgcleanup did anything.

        * gcc.dg/pr52045.c: New testcase.

Index: gcc/tree-optimize.c
===================================================================
--- gcc/tree-optimize.c (revision 183695)
+++ gcc/tree-optimize.c (working copy)
@@ -157,7 +157,9 @@ struct gimple_opt_pass pass_all_early_op
 static unsigned int
 execute_cleanup_cfg_post_optimizing (void)
 {
-  cleanup_tree_cfg ();
+  unsigned int todo = 0;
+  if (cleanup_tree_cfg ())
+    todo |= TODO_update_ssa;
   maybe_remove_unreachable_handlers ();
   cleanup_dead_labels ();
   group_case_labels ();
@@ -190,7 +192,7 @@ execute_cleanup_cfg_post_optimizing (voi
            }
        }
     }
-  return 0;
+  return todo;
 }
 
 struct gimple_opt_pass pass_cleanup_cfg_post_optimizing =
Index: gcc/testsuite/gcc.dg/pr52045.c
===================================================================
--- gcc/testsuite/gcc.dg/pr52045.c      (revision 0)
+++ gcc/testsuite/gcc.dg/pr52045.c      (revision 0)
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options "-O3 -ftracer -fno-tree-ccp -fno-tree-copy-prop -fno-tree-dce" 
} */
+
+char *vx;
+char buf[20];
+
+void
+foo (void)
+{
+  vx = __builtin___stpcpy_chk (buf, vx ? "gh" : "e", sizeof(buf));
+}

Reply via email to