From: Jakub Jelinek Date: Sun, 1 Feb 2015 21:56:03 +0000 (+0100) Subject: backport: re PR rtl-optimization/61058 (ICE: RTL check: expected elt 3 type 'B',... X-Git-Tag: releases/gcc-4.8.5~292 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=27e12a502c12b39ba874124183f6b7461785fdcc;p=thirdparty%2Fgcc.git backport: re PR rtl-optimization/61058 (ICE: RTL check: expected elt 3 type 'B', have '0' (rtx barrier) in distance_agu_use_in_bb, at config/i386/i386.c:16740 with __builtin_unreachable()) Backported from mainline 2015-01-27 Jakub Jelinek 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. 2013-04-16 Steven Bosscher PR middle-end/43631 * jump.c (cleanup_barriers): Use reorder_insns_nobb to avoid making the moved barrier the tail of the basic block it follows. From-SVN: r220336 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 1de6c3960f93..246c8d7d9067 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,6 +1,18 @@ 2015-02-01 Jakub Jelinek Backported from mainline + 2015-01-27 Jakub Jelinek + + PR rtl-optimization/61058 + * jump.c (cleanup_barriers): Update basic block boundaries + if BLOCK_FOR_INSN is non-NULL on PREV. + + 2013-04-16 Steven Bosscher + + PR middle-end/43631 + * jump.c (cleanup_barriers): Use reorder_insns_nobb to avoid making + the moved barrier the tail of the basic block it follows. + 2015-01-26 Jakub Jelinek * config/rs6000/rs6000-cpus.def (POWERPC_MASKS): Add diff --git a/gcc/jump.c b/gcc/jump.c index 54d98605dfc4..8a0b5811b5c6 100644 --- a/gcc/jump.c +++ b/gcc/jump.c @@ -133,7 +133,30 @@ cleanup_barriers (void) if (BARRIER_P (prev)) delete_insn (insn); else if (prev != PREV_INSN (insn)) - reorder_insns (insn, insn, prev); + { + basic_block bb = BLOCK_FOR_INSN (prev); + rtx 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; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d78cf365d6ca..f0d9e5e328dc 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -3,6 +3,9 @@ Backported from mainline 2015-01-27 Jakub Jelinek + PR rtl-optimization/61058 + * gcc.dg/pr61058.c: New test. + PR c/64766 * gcc.dg/pr64766.c: New test. diff --git a/gcc/testsuite/gcc.dg/pr61058.c b/gcc/testsuite/gcc.dg/pr61058.c new file mode 100644 index 000000000000..6f840f418fee --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr61058.c @@ -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 (); +}