From: Martin Liska Date: Wed, 13 Feb 2019 06:57:38 +0000 (+0100) Subject: Remove a barrier when EDGE_CROSSING is removed (PR lto/88858). X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=91c50487de75a5275e2e8c2e1cd4b10f3a59b7df;p=gcc.git Remove a barrier when EDGE_CROSSING is removed (PR lto/88858). 2019-02-13 Martin Liska PR lto/88858 * cfgrtl.c (remove_barriers_from_footer): New function. (try_redirect_by_replacing_jump): Use it. (cfg_layout_redirect_edge_and_branch): Likewise. From-SVN: r268835 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c866e2d6dc9..533ab59b6bb 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2019-02-13 Martin Liska + + PR lto/88858 + * cfgrtl.c (remove_barriers_from_footer): New function. + (try_redirect_by_replacing_jump): Use it. + (cfg_layout_redirect_edge_and_branch): Likewise. + 2019-02-13 Xiong Hu Luo * config/rs6000/altivec.h (vec_sbox_be, vec_cipher_be, diff --git a/gcc/cfgrtl.c b/gcc/cfgrtl.c index 172bdf585d0..56564c2fda7 100644 --- a/gcc/cfgrtl.c +++ b/gcc/cfgrtl.c @@ -988,6 +988,31 @@ block_label (basic_block block) return as_a (BB_HEAD (block)); } +/* Remove all barriers from BB_FOOTER of a BB. */ + +static void +remove_barriers_from_footer (basic_block bb) +{ + rtx_insn *insn = BB_FOOTER (bb); + + /* Remove barriers but keep jumptables. */ + while (insn) + { + if (BARRIER_P (insn)) + { + if (PREV_INSN (insn)) + SET_NEXT_INSN (PREV_INSN (insn)) = NEXT_INSN (insn); + else + BB_FOOTER (bb) = NEXT_INSN (insn); + if (NEXT_INSN (insn)) + SET_PREV_INSN (NEXT_INSN (insn)) = PREV_INSN (insn); + } + if (LABEL_P (insn)) + return; + insn = NEXT_INSN (insn); + } +} + /* Attempt to perform edge redirection by replacing possibly complex jump instruction by unconditional jump or removing jump completely. This can apply only if all edges now point to the same block. The parameters and @@ -1051,26 +1076,8 @@ try_redirect_by_replacing_jump (edge e, basic_block target, bool in_cfglayout) /* Selectively unlink whole insn chain. */ if (in_cfglayout) { - rtx_insn *insn = BB_FOOTER (src); - delete_insn_chain (kill_from, BB_END (src), false); - - /* Remove barriers but keep jumptables. */ - while (insn) - { - if (BARRIER_P (insn)) - { - if (PREV_INSN (insn)) - SET_NEXT_INSN (PREV_INSN (insn)) = NEXT_INSN (insn); - else - BB_FOOTER (src) = NEXT_INSN (insn); - if (NEXT_INSN (insn)) - SET_PREV_INSN (NEXT_INSN (insn)) = PREV_INSN (insn); - } - if (LABEL_P (insn)) - break; - insn = NEXT_INSN (insn); - } + remove_barriers_from_footer (src); } else delete_insn_chain (kill_from, PREV_INSN (BB_HEAD (target)), @@ -4396,6 +4403,7 @@ cfg_layout_redirect_edge_and_branch (edge e, basic_block dest) "Removing crossing jump while redirecting edge form %i to %i\n", e->src->index, dest->index); delete_insn (BB_END (src)); + remove_barriers_from_footer (src); e->flags |= EDGE_FALLTHRU; }