http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48486

           Summary: cfgexpand leaves BARRIERs at the end of basic blocks
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: ste...@gcc.gnu.org


Consider this code, following the expansion of a gimple switch statement:

(gdb) call debug_rtx_list(last, -7)
(insn 594 593 595 (set (reg/f:DI 809)
        (label_ref:DI 598))
../../../../trunk/libgcc/../gcc/config/soft-fp/divtf3.c:44 -1
     (nil))

(insn 595 594 596 (set (reg:DI 810)
        (mem/u/c:DI (plus:DI (mult:DI (reg:DI 808)
                    (const_int 8 [0x8]))
                (reg/f:DI 809)) [0 S8 A8]))
../../../../trunk/libgcc/../gcc/config/soft-fp/divtf3.c:44 -1
     (nil))

(jump_insn 596 595 597 (parallel [
            (set (pc)
                (reg:DI 810))
            (use (label_ref 598))
        ]) ../../../../trunk/libgcc/../gcc/config/soft-fp/divtf3.c:44 -1
     (nil))

(barrier 597 596 598)

(code_label 598 597 599 46 "" [0 uses])

(jump_insn 599 598 600 (addr_vec:DI [
            (label_ref:DI 0)
            (label_ref:DI 0)
            (label_ref:DI 0)
            (label_ref:DI 0)
            (label_ref:DI 0)
            (label_ref:DI 0)
            (label_ref:DI 0)
            (label_ref:DI 0)
            (label_ref:DI 0)
            (label_ref:DI 0)
            (label_ref:DI 0)
            (label_ref:DI 0)
            (label_ref:DI 0)
            (label_ref:DI 0)
            (label_ref:DI 0)
            (label_ref:DI 0)
        ]) ../../../../trunk/libgcc/../gcc/config/soft-fp/divtf3.c:44 -1
     (nil))

(barrier 600 599 0)

At this point:
(gbd) p debug_rtx (get_last_insn())
(barrier 600 599 0)
$24 = void

Now cfgexpand tries to avoid having BARRIERs at the end of a basic block
because that is, well, wrong to have. So:

  /* Find the block tail.  The last insn in the block is the insn
     before a barrier and/or table jump insn.  */
  last = get_last_insn ();
  if (BARRIER_P (last))
    last = PREV_INSN (last);
  if (JUMP_TABLE_DATA_P (last))
    last = PREV_INSN (PREV_INSN (last));
  BB_END (bb) = last;

(gdb) p debug_rtx(last)
(barrier 597 596 598)
$25 = void
(gdb)

Reply via email to