]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR rtl-optimization/52139 (ICE: in remove_insn, at emit-rtl.c:3960 with -O -fPIC...
authorJakub Jelinek <jakub@redhat.com>
Wed, 8 Feb 2012 12:29:43 +0000 (13:29 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 8 Feb 2012 12:29:43 +0000 (13:29 +0100)
PR rtl-optimization/52139
* cfgrtl.c (cfg_layout_merge_blocks): If BB_END
is a BARRIER after emit_insn_after_noloc, move BB_END
to the last non-BARRIER insn before it.

* gcc.dg/pr52139.c: New test.

From-SVN: r184005

gcc/ChangeLog
gcc/cfgrtl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr52139.c [new file with mode: 0644]

index 8ea5882f934116c3df0d15411cd35256642f49e0..5398c68c7c9ac3cd41c12aeafacf755e30f1ebb4 100644 (file)
@@ -1,3 +1,10 @@
+2012-02-08  Jakub Jelinek  <jakub@redhat.com>
+
+       PR rtl-optimization/52139
+       * cfgrtl.c (cfg_layout_merge_blocks): If BB_END
+       is a BARRIER after emit_insn_after_noloc, move BB_END
+       to the last non-BARRIER insn before it.
+
 2012-02-07  Richard Sandiford  <rdsandiford@googlemail.com>
 
        PR middle-end/24306
index bcc410a8b4a7347bbe9cd29c5f99154559ae4813..8283da09992b20d430add096c756450ed930f774 100644 (file)
@@ -2871,6 +2871,11 @@ cfg_layout_merge_blocks (basic_block a, basic_block b)
       rtx first = BB_END (a), last;
 
       last = emit_insn_after_noloc (b->il.rtl->header, BB_END (a), a);
+      /* The above might add a BARRIER as BB_END, but as barriers
+        aren't valid parts of a bb, remove_insn doesn't update
+        BB_END if it is a barrier.  So adjust BB_END here.  */
+      while (BB_END (a) != first && BARRIER_P (BB_END (a)))
+       BB_END (a) = PREV_INSN (BB_END (a));
       delete_insn_chain (NEXT_INSN (first), last, false);
       b->il.rtl->header = NULL;
     }
index 482b4899dd13ffa07648cf3ef76e08a434711ffd..366103e6d1ae27e6ae2cf8c07ca2705fc42e62cd 100644 (file)
@@ -1,3 +1,8 @@
+2012-02-08  Jakub Jelinek  <jakub@redhat.com>
+
+       PR rtl-optimization/52139
+       * gcc.dg/pr52139.c: New test.
+
 2012-02-07  Jason Merrill  <jason@redhat.com>
 
        PR c++/51675
diff --git a/gcc/testsuite/gcc.dg/pr52139.c b/gcc/testsuite/gcc.dg/pr52139.c
new file mode 100644 (file)
index 0000000..bd654a2
--- /dev/null
@@ -0,0 +1,49 @@
+/* PR rtl-optimization/52139 */
+/* { dg-do compile } */
+/* { dg-options "-O -fno-tree-dominator-opts -fno-tree-fre" } */
+/* { dg-additional-options "-fpic" { target fpic } } */
+
+void *p;
+
+void
+foo (int a)
+{
+  switch (a)
+    {
+    case 0:
+    a0:
+    case 1:
+    a1:
+      p = &&a1;
+    case 2:
+    a2:
+      p = &&a2;
+    case 3:
+    a3:
+      p = &&a3;
+    case 4:
+    a4:
+      p = &&a4;
+    case 5:
+    a5:
+      p = &&a5;
+    case 6:
+    a6:
+      p = &&a6;
+    case 7:
+    a7:
+      p = &&a7;
+    case 8:
+    a8:
+      p = &&a8;
+    case 9:
+    a9:
+      p = &&a9;
+    case 10:
+    a10:
+      p = &&a10;
+    default:
+      p = &&a0;
+    }
+  goto *p;
+}