Patchwork [PR,debug/45136] revamp handling of BB boundary debug insns in sched

login
register
mail settings
Submitter Ulrich Weigand
Date Jan. 30, 2011, 3:13 a.m.
Message ID <201101300313.p0U3DNJ0007545@d06av02.portsmouth.uk.ibm.com>
Download mbox | patch
Permalink /patch/80995/
State New
Headers show

Comments

Ulrich Weigand - Jan. 30, 2011, 3:13 a.m.
Alexandre Oliva wrote:

> 	PR debug/45136
> 	PR debug/45130
> 	* haifa-sched.c (get_ebb_head_tail): Move notes across boundary
> 	debug insns.
> 	(no_real_insns_p, schedule_block, set_priorities): Drop special
> 	treatment of boundary debug insns.
> 	* sched-deps.c (sd_init_insn, sd_finish_insn): Don't mark debug
> 	insns.
> 	* sched-ebb.c (schedule_ebbs): Don't skip debug insns.
> 	* sched-int.h (DEBUG_INSN_SCHED_P): Remove.
> 	(BOUNDARY_DEBUG_INSN_P): Likewise.
> 	(SCHEDULE_DEBUG_INSN_P): Likewise.
> 	* sched-rgn.c (init_ready_list): Drop special treatment of
> 	boundary debug insns.
> 	* final.c (rest_of_clean-state): Clear notes' BB.

This seems to have caused a regression on SPU:
FAIL: gcc.dg/pr42918.c (test for excess errors)

The problem is that a note is moved to someplace else after it
was moved to a different basic block in get_ebb_head_tail:


Before sched1, the note is here:

(note 23 22 24 5 [bb 5] NOTE_INSN_BASIC_BLOCK)

(call_insn 24 23 25 5 (parallel [
            (call (mem:QI (symbol_ref:SI ("fv") [flags 0x41]  <function_decl 0xf6f0ca00 fv>) [0 S1 A8])
                (const_int 0 [0]))
            (clobber (reg:SI 0 $lr))
            (clobber (reg:SI 130 hbr))
        ]) /home/uweigand/fsf/gcc-head/gcc/testsuite/gcc.dg/pr42918.c:18 419 {_call}
     (nil)
    (nil))

(note 25 24 30 5 ("lab") NOTE_INSN_DELETED_LABEL 3)
;; End of basic block 5 -> ( 6)
;; lr  out       1 [$sp] 127 [$127] 128 [$vfp] 129 [$vap] 140
;; live  out     1 [$sp] 127 [$127] 128 [$vfp] 129 [$vap] 140

Without debug info, it stays here after sched1.

*With* debug info, we also have a debug_insn:

(note 25 24 26 5 [bb 5] NOTE_INSN_BASIC_BLOCK)

(call_insn 26 25 27 5 (parallel [
            (call (mem:QI (symbol_ref:SI ("fv") [flags 0x41]  <function_decl 0xf6f2ca00 fv>) [0 S1 A8])
                (const_int 0 [0]))
            (clobber (reg:SI 0 $lr))
            (clobber (reg:SI 130 hbr))
        ]) /home/uweigand/fsf/gcc-head/gcc/testsuite/gcc.dg/pr42918.c:18 419 {_call}
     (nil)
    (nil))

(note 27 26 29 5 ("lab") NOTE_INSN_DELETED_LABEL 3)

(debug_insn 29 27 33 5 (var_location:SI i (reg/v:SI 140 [ i ])) -1
     (nil))
;; End of basic block 5 -> ( 6)
;; lr  out       1 [$sp] 127 [$127] 128 [$vfp] 129 [$vap] 140
;; live  out     1 [$sp] 127 [$127] 128 [$vfp] 129 [$vap] 140

The new code in get_ebb_head_tail now moves the note into another
basic block:

(call_insn 26 25 29 5 (parallel [
            (call (mem:QI (symbol_ref:SI ("fv") [flags 0x41]  <function_decl 0xf6f2ca00 fv>) [0 S1 A8])
                (const_int 0 [0]))
            (clobber (reg:SI 0 $lr))
            (clobber (reg:SI 130 hbr))
        ]) /home/uweigand/fsf/gcc-head/gcc/testsuite/gcc.dg/pr42918.c:18 419 {_call}
     (nil)
    (nil))

(debug_insn 29 26 27 5 (var_location:SI i (reg/v:SI 140 [ i ])) -1
     (nil))
;; End of basic block 5 -> ( 6)
;; lr  out       1 [$sp] 127 [$127] 128 [$vfp] 129 [$vap] 140
;; live  out     1 [$sp] 127 [$127] 128 [$vfp] 129 [$vap] 140


;; Succ edge  6 [100.0%]  (fallthru)

(note 27 29 33 ("lab") NOTE_INSN_DELETED_LABEL 3)

After basic block reordering and various other optimizations, this
means the note ends up in a completely different location in the
final output.


The move into a different block occurs here:

  while (end_head != end_tail)
    if (NOTE_P (end_tail))
      end_tail = PREV_INSN (end_tail);
    else if (DEBUG_INSN_P (end_tail))
      {
        rtx note, prev;

        for (note = PREV_INSN (end_tail);
             note != end_head;
             note = prev)
          {
            prev = PREV_INSN (note);
            if (NOTE_P (note))
              {
                if (sched_verbose >= 9)
                  fprintf (sched_dump, "reorder %i\n", INSN_UID (note));

                reorder_insns_nobb (note, note, end_tail);

                if (end_tail == BB_END (end))
                  df_insn_change_bb (note, NULL);

Why is this df_insn_change_bb call necessary?

Bye,
Ulrich

Patch

--- pr42918.gkd 2011-01-30 03:31:48.000000000 +0100
+++ pr42918.gk.gkd      2011-01-30 04:05:07.000000000 +0100
@@ -100,6 +100,7 @@ 
         (expr_list:REG_BR_PROB (const_int 1990 [0x7c6])
             (nil)))
  -> 5)
+(note# 0 0 ("lab") NOTE_INSN_DELETED_LABEL 3)
 (note# 0 0 [bb 4] NOTE_INSN_BASIC_BLOCK)
 (insn# 0 0 (use (reg/i:SI 3 $3)) /home/uweigand/fsf/gcc-head/gcc/testsuite/gcc.dg/pr42918.c:21#
      (nil))
@@ -124,7 +125,6 @@ 
 (barrier 0 0 0)
 (code_label 5 0 0 5 "" [2 uses])
 (note# 0 0 [bb 5] NOTE_INSN_BASIC_BLOCK)
-(note# 0 0 ("lab") NOTE_INSN_DELETED_LABEL 3)
 (insn:TI# 0 0 (set (mem/c:TI (plus:SI (reg/f:SI 1 $sp)
                 (const_int 32 [0x20])) [ S16 A128])
         (reg:TI 3 $3)) /home/uweigand/fsf/gcc-head/gcc/testsuite/gcc.dg/pr42918.c:18# {_movti}