re PR tree-optimization/47355 (ICE: verify_ssa failed with -O2 -fipa-cp-clone)
authorJakub Jelinek <jakub@redhat.com>
Fri, 21 Jan 2011 15:15:40 +0000 (16:15 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 21 Jan 2011 15:15:40 +0000 (16:15 +0100)
PR tree-optimization/47355
* tree-eh.c (cleanup_empty_eh_merge_phis): Give up if
NOP has non-debug uses beyond PHIs in new_bb.

* g++.dg/opt/pr47355.C: New test.

From-SVN: r169094

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/opt/pr47355.C [new file with mode: 0644]
gcc/tree-eh.c

index 36ad66e6e88a158e8a648260ca87ef747cf0cff8..09a73394d35bd33d2228197214180d77aebaa97c 100644 (file)
@@ -1,3 +1,9 @@
+2011-01-21  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/47355
+       * tree-eh.c (cleanup_empty_eh_merge_phis): Give up if
+       NOP has non-debug uses beyond PHIs in new_bb.
+
 2011-01-21  Alexandre Oliva  <aoliva@redhat.com>
 
        PR debug/47106
index 61b3d23ab1c70b65195d8c5a77e4be80626897ff..8cef703342311aee01021b91cae1ea644264ce5b 100644 (file)
@@ -1,3 +1,8 @@
+2011-01-21  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/47355
+       * g++.dg/opt/pr47355.C: New test.
+
 2011-01-21  Richard Guenther  <rguenther@suse.de>
 
        * gcc.dg/tree-ssa/pr47392.c: Make test non-static instead of
diff --git a/gcc/testsuite/g++.dg/opt/pr47355.C b/gcc/testsuite/g++.dg/opt/pr47355.C
new file mode 100644 (file)
index 0000000..4fdbd9f
--- /dev/null
@@ -0,0 +1,39 @@
+// PR tree-optimization/47355
+// { dg-do compile }
+// { dg-options "-O -fipa-cp -fipa-cp-clone" }
+
+struct T
+{
+  T ();
+  void *p;
+  ~T ();
+};
+
+void foo (T *i);
+
+T *bar ();
+void baz (T *);
+
+struct V
+{
+  long q;
+  T *r;
+  ~V ()
+  {
+    while (q)
+      {
+       foo (r);
+       ++r;
+       --q;
+      }
+    baz (r);
+  }
+};
+
+void
+foo ()
+{
+  V v;
+  T t;
+  v.r = bar ();
+}
index 65d0ff2f9fd903f8ea8917fdd15eb228ca0fc81b..f189b9b6a96c0a805b55a7b580e65c6ea456aa2f 100644 (file)
@@ -3552,6 +3552,20 @@ cleanup_empty_eh_merge_phis (basic_block new_bb, basic_block old_bb,
       /* If we did find the corresponding PHI, copy those inputs.  */
       if (ophi)
        {
+         /* If NOP is used somewhere else beyond phis in new_bb, give up.  */
+         if (!has_single_use (nop))
+           {
+             imm_use_iterator imm_iter;
+             use_operand_p use_p;
+
+             FOR_EACH_IMM_USE_FAST (use_p, imm_iter, nop)
+               {
+                 if (!gimple_debug_bind_p (USE_STMT (use_p))
+                     && (gimple_code (USE_STMT (use_p)) != GIMPLE_PHI
+                         || gimple_bb (USE_STMT (use_p)) != new_bb))
+                   goto fail;
+               }
+           }
          bitmap_set_bit (ophi_handled, SSA_NAME_VERSION (nop));
          FOR_EACH_EDGE (e, ei, old_bb->preds)
            {