Remove a barrier when EDGE_CROSSING is removed (PR lto/88858).
authorMartin Liska <mliska@suse.cz>
Wed, 13 Feb 2019 06:57:38 +0000 (07:57 +0100)
committerMartin Liska <marxin@gcc.gnu.org>
Wed, 13 Feb 2019 06:57:38 +0000 (06:57 +0000)
2019-02-13  Martin Liska  <mliska@suse.cz>

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

gcc/ChangeLog
gcc/cfgrtl.c

index c866e2d6dc93a2adea766dfffd1aa1b979840e17..533ab59b6bbf7df7f9f2c1421d1864a6c57427d8 100644 (file)
@@ -1,3 +1,10 @@
+2019-02-13  Martin Liska  <mliska@suse.cz>
+
+       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  <luoxhu@linux.vnet.ibm.com>
 
        * config/rs6000/altivec.h (vec_sbox_be, vec_cipher_be,
index 172bdf585d036e27bcf53dba89c1ffc1b6cb84c7..56564c2fda7aa03b0283e545fd222066dfd1dc39 100644 (file)
@@ -988,6 +988,31 @@ block_label (basic_block block)
   return as_a <rtx_code_label *> (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;
     }