re PR rtl-optimization/61058 (ICE: RTL check: expected elt 3 type 'B', have '0' ...
authorJakub Jelinek <jakub@redhat.com>
Tue, 27 Jan 2015 09:19:30 +0000 (10:19 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 27 Jan 2015 09:19:30 +0000 (10:19 +0100)
PR rtl-optimization/61058
* jump.c (cleanup_barriers): Update basic block boundaries
if BLOCK_FOR_INSN is non-NULL on PREV.

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

From-SVN: r220155

gcc/ChangeLog
gcc/jump.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr61058.c [new file with mode: 0644]

index 5597e32b3f9c2325505cf8c0c0124843c1de3267..57f5efe08fb6a86e6b7648904b312f3a05257d58 100644 (file)
@@ -1,3 +1,9 @@
+2015-01-27  Jakub Jelinek  <jakub@redhat.com>
+
+       PR rtl-optimization/61058
+       * jump.c (cleanup_barriers): Update basic block boundaries
+       if BLOCK_FOR_INSN is non-NULL on PREV.
+
 2015-01-27  Ilya Enkovich  <ilya.enkovich@intel.com>
 
        * tree-chkp.c (chkp_call_returns_bounds_p): Fix handling of
index 3b8c91e007fe879bff00aa85c24b2b965fc685ce..34b3b7b893297d8577d56fc29e2d34a8c101f1fd 100644 (file)
@@ -168,7 +168,30 @@ cleanup_barriers (void)
          if (BARRIER_P (prev))
            delete_insn (insn);
          else if (prev != PREV_INSN (insn))
-           reorder_insns_nobb (insn, insn, prev);
+           {
+             basic_block bb = BLOCK_FOR_INSN (prev);
+             rtx_insn *end = PREV_INSN (insn);
+             reorder_insns_nobb (insn, insn, prev);
+             if (bb)
+               {
+                 /* If the backend called in machine reorg compute_bb_for_insn
+                    and didn't free_bb_for_insn again, preserve basic block
+                    boundaries.  Move the end of basic block to PREV since
+                    it is followed by a barrier now, and clear BLOCK_FOR_INSN
+                    on the following notes.
+                    ???  Maybe the proper solution for the targets that have
+                    cfg around after machine reorg is not to run cleanup_barriers
+                    pass at all.  */
+                 BB_END (bb) = prev;
+                 do
+                   {
+                     prev = NEXT_INSN (prev);
+                     if (prev != insn && BLOCK_FOR_INSN (prev) == bb)
+                       BLOCK_FOR_INSN (prev) = NULL;
+                   }
+                 while (prev != end);
+               }
+           }
        }
     }
   return 0;
index 0686fa7caaa4fc91bba94b1c2fea3938e90ce8ec..8bcb32a0e39f3654ae6a47142dead33a33bc7396 100644 (file)
@@ -1,3 +1,8 @@
+2015-01-27  Jakub Jelinek  <jakub@redhat.com>
+
+       PR rtl-optimization/61058
+       * gcc.dg/pr61058.c: New test.
+
 2015-01-27  Ilya Enkovich  <ilya.enkovich@intel.com>
 
        * gcc.target/i386/chkp-narrow-bounds.c: New.
diff --git a/gcc/testsuite/gcc.dg/pr61058.c b/gcc/testsuite/gcc.dg/pr61058.c
new file mode 100644 (file)
index 0000000..6f840f4
--- /dev/null
@@ -0,0 +1,10 @@
+/* PR rtl-optimization/61058 */
+/* { dg-do compile } */
+/* { dg-options "" } */
+/* { dg-additional-options "-fno-asynchronous-unwind-tables -mtune=atom" { target i?86-*-* x86_64-*-* } } */
+
+void
+foo (void)
+{
+  __builtin_unreachable ();
+}