Hi,

This patch fixed a bug exposed in build kernel with fdo.

We cannot simply overwrite the bb footer in  emit_barrier_after_bb as
the bb may already have a footer (in this case, a deleted label stmt).
We need to output this label because it's a user label and debug_info
has a reference to it.

Tested with problematic file and regression test.
Trunk may also have the same issue, but I need to work on a testcase.

Thanks,

-Rong
2014-10-02  Rong Xu  <x...@google.com>

        * gcc/cfgrtl.c (emit_barrier_after_bb): Append footer instead of
        overwriting.

Index: gcc/cfgrtl.c
===================================================================
--- gcc/cfgrtl.c        (revision 215823)
+++ gcc/cfgrtl.c        (working copy)
@@ -1453,7 +1453,20 @@ emit_barrier_after_bb (basic_block bb)
   gcc_assert (current_ir_type () == IR_RTL_CFGRTL
               || current_ir_type () == IR_RTL_CFGLAYOUT);
   if (current_ir_type () == IR_RTL_CFGLAYOUT)
-    BB_FOOTER (bb) = unlink_insn_chain (barrier, barrier);
+    {
+      rtx insn = unlink_insn_chain (barrier, barrier);
+
+      if (BB_FOOTER (bb))
+       {
+          rtx footer_tail = BB_FOOTER (bb);
+          while (NEXT_INSN(footer_tail))
+            footer_tail = NEXT_INSN (insn);
+         NEXT_INSN (footer_tail) = insn;
+         PREV_INSN (insn) = footer_tail;
+       }
+      else
+        BB_FOOTER (bb) = insn;
+    }
 }
 
 /* Like force_nonfallthru below, but additionally performs redirection

Reply via email to