From: Jakub Jelinek Date: Thu, 9 Feb 2012 21:39:20 +0000 (+0100) Subject: backport: re PR rtl-optimization/52139 (ICE: in remove_insn, at emit-rtl.c:3960 with... X-Git-Tag: releases/gcc-4.5.4~227 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c8b7e7bb8d2778c2bcfafd714e1604fa1aee9b99;p=thirdparty%2Fgcc.git backport: re PR rtl-optimization/52139 (ICE: in remove_insn, at emit-rtl.c:3960 with -O -fPIC -fno-tree-dominator-opts -fno-tree-fre) Backported from mainline 2012-02-08 Jakub Jelinek 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: r184074 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index eaa27374ff7e..7705d34ba739 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,6 +1,13 @@ 2012-02-09 Jakub Jelinek Backported from mainline + 2012-02-08 Jakub Jelinek + + 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-01-19 Jakub Jelinek PR libmudflap/40778 diff --git a/gcc/cfgrtl.c b/gcc/cfgrtl.c index 814ad7846f42..c197b0eac98c 100644 --- a/gcc/cfgrtl.c +++ b/gcc/cfgrtl.c @@ -2790,6 +2790,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; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1c950d84b858..d4ef9a7626d1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,6 +1,11 @@ 2012-02-09 Jakub Jelinek Backported from mainline + 2012-02-08 Jakub Jelinek + + PR rtl-optimization/52139 + * gcc.dg/pr52139.c: New test. + 2012-01-05 Jakub Jelinek PR rtl-optimization/51767 diff --git a/gcc/testsuite/gcc.dg/pr52139.c b/gcc/testsuite/gcc.dg/pr52139.c new file mode 100644 index 000000000000..d10adf2b6fb0 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr52139.c @@ -0,0 +1,49 @@ +/* PR rtl-optimization/52139 */ +/* { dg-do compile } */ +/* { dg-options "-O -fno-tree-dominator-opts -fno-tree-fre" } */ +/* { dg-options "-O -fno-tree-dominator-opts -fno-tree-fre -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; +}