re PR rtl-optimization/90026 (ICE: verify_flow_info failed (error: missing barrier...
authorJakub Jelinek <jakub@redhat.com>
Fri, 12 Apr 2019 07:27:25 +0000 (09:27 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 12 Apr 2019 07:27:25 +0000 (09:27 +0200)
PR rtl-optimization/90026
* cfgcleanup.c (try_optimize_cfg): When removing empty bb with no
successors, look for BARRIERs inside of the whole BB_FOOTER chain
rather than just at the start of it.  If e->src BB_FOOTER is not NULL
in cfglayout mode, use emit_barrier_after_bb.

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

From-SVN: r270304

gcc/ChangeLog
gcc/cfgcleanup.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/opt/pr90026.C [new file with mode: 0644]

index 970bdf8a4f54f2ead60ace479d97afd1c2b4b8b6..a5dda2bedec37b42c2230313239da085c737f8f2 100644 (file)
@@ -1,3 +1,11 @@
+2019-04-12  Jakub Jelinek  <jakub@redhat.com>
+
+       PR rtl-optimization/90026
+       * cfgcleanup.c (try_optimize_cfg): When removing empty bb with no
+       successors, look for BARRIERs inside of the whole BB_FOOTER chain
+       rather than just at the start of it.  If e->src BB_FOOTER is not NULL
+       in cfglayout mode, use emit_barrier_after_bb.
+
 2018-04-11  Steve Ellcey  <sellcey@marvell.com>
 
        PR rtl-optimization/87763
index 86b262750330a29c56a4bbabf07e28fe07c9ded3..992912ce19588cd25ca800f58f0d56ee4b5b9329 100644 (file)
@@ -2712,23 +2712,23 @@ try_optimize_cfg (int mode)
 
                      if (current_ir_type () == IR_RTL_CFGLAYOUT)
                        {
-                         if (BB_FOOTER (b)
-                             && BARRIER_P (BB_FOOTER (b)))
+                         rtx_insn *insn;
+                         for (insn = BB_FOOTER (b);
+                              insn; insn = NEXT_INSN (insn))
+                           if (BARRIER_P (insn))
+                             break;
+                         if (insn)
                            FOR_EACH_EDGE (e, ei, b->preds)
-                             if ((e->flags & EDGE_FALLTHRU)
-                                 && BB_FOOTER (e->src) == NULL)
+                             if ((e->flags & EDGE_FALLTHRU))
                                {
-                                 if (BB_FOOTER (b))
+                                 if (BB_FOOTER (b)
+                                     && BB_FOOTER (e->src) == NULL)
                                    {
                                      BB_FOOTER (e->src) = BB_FOOTER (b);
                                      BB_FOOTER (b) = NULL;
                                    }
                                  else
-                                   {
-                                     start_sequence ();
-                                     BB_FOOTER (e->src) = emit_barrier ();
-                                     end_sequence ();
-                                   }
+                                   emit_barrier_after_bb (e->src);
                                }
                        }
                      else
index 840df424cb2b068bde74c63346eea19defc7c48e..d66bc36415c0afd3f099f127636cde915e0e13ce 100644 (file)
@@ -1,3 +1,8 @@
+2019-04-12  Jakub Jelinek  <jakub@redhat.com>
+
+       PR rtl-optimization/90026
+       * g++.dg/opt/pr90026.C: New test.
+
 2018-04-11  Steve Ellcey  <sellcey@marvell.com>
 
        PR rtl-optimization/87763
diff --git a/gcc/testsuite/g++.dg/opt/pr90026.C b/gcc/testsuite/g++.dg/opt/pr90026.C
new file mode 100644 (file)
index 0000000..3971ef0
--- /dev/null
@@ -0,0 +1,24 @@
+// PR rtl-optimization/90026
+// { dg-do compile }
+// { dg-options "-fnon-call-exceptions -ftracer -O2 -w" }
+
+typedef __SIZE_TYPE__ size_t;
+struct S { int *b; ~S () { delete b; } };
+void bar ();
+char c[sizeof (int)];
+
+void *
+operator new (size_t, void *)
+{
+  __builtin_unreachable ();
+}
+
+void
+foo ()
+{
+  S a;
+  if (a.b)
+    a.b = new int ();
+  bar ();
+  new (c) int ();
+}