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

--- Comment #11 from John David Anglin <danglin at gcc dot gnu.org> 2011-05-23 
02:39:31 UTC ---
It seems to me the following is broken:

   Once we have found a basic block and a corresponding first insn, we can
   accurately compute the live status (by starting at a label following a
   BARRIER, we are immune to actions taken by reload and jump.)  Then we
   scan all insns between that point and our target.  For each CLOBBER (or
   for call-clobbered regs when we pass a CALL_INSN), mark the appropriate
   registers are dead.  For a SET, mark them as live.

In this case, we have at the start of the first search:

Breakpoint 12, mark_target_live_regs (insns=0x1b8a020, target=0x1b98f90,
res=0xbfffeda0) at ../../gcc/gcc/resource.c:975
975          for (insn = start_insn; insn != stop_insn;
(gdb) p debug_rtx_list (start_insn, 12)
(code_label 322 386 91 16 617 "" [1 uses])

(note 91 322 433 [bb 16] NOTE_INSN_BASIC_BLOCK)

(insn 433 91 64 (use (insn/s 92 59 366 (set (reg/v:SI 4 %r4 [orig:111 i ]
[111])
                (const_int 2 [0x2])) 37 {*pa.md:2542} (expr_list:REG_EQUAL
(const_int 2 [0x2])
                (nil)))) -1 (nil))

The actual set for %r4 is in bb 10:

(insn 434 58 366 ../../gcc/gcc/basic-block.h:194 (sequence [
            (jump_insn 59 58 92 ../../gcc/gcc/basic-block.h:194 (set (pc)
                    (if_then_else (gtu (reg:SI 28 %r28 [orig:132
<variable>.base.num ] [132])
                            (const_int 2 [0x2]))
                        (label_ref:SI 322)
                        (pc))) 25 {*pa.md:1770} (expr_list:REG_DEAD (reg:SI 28
%r28 [orig:132 <variable>.base.num ] [132])
                    (expr_list:REG_BR_PROB (const_int 9700 [0x25e4])
                        (nil))))
            (insn/s 92 59 366 (set (reg/v:SI 4 %r4 [orig:111 i ] [111])
                    (const_int 2 [0x2])) 37 {*pa.md:2542} (expr_list:REG_EQUAL
(const_int 2 [0x2])
                    (nil)))
        ]) -1 (nil))

On the next iteration, insn 433 has been deleted but regs_live at
the start of bb 16 is still the same as before:

Breakpoint 12, mark_target_live_regs (insns=0x1b8a020, target=0x1b98f90,
res=0xbfffeda0) at ../../gcc/gcc/resource.c:975
975          for (insn = start_insn; insn != stop_insn;
(gdb) p debug_rtx_list (start_insn, 12)
(note 91 386 465 [bb 16] NOTE_INSN_BASIC_BLOCK)

(code_label 465 91 464 624 "" [1 uses])

(insn 464 465 65 (use (insn/v 64 91 465 ../../gcc/gcc/tree-cfgcleanup.c:697
(set (reg/f:SI 1 %r1 [216])
                (high:SI (symbol_ref:SI ("cfun") [flags 0x240] <var_decl
0xc204e0 cfun>))) 49 {*pa.md:3017} (expr_list:REG_EQUIV (high:SI (symbol_ref:SI
("cfun") [flags 0x240] <var_decl 0xc204e0 cfun>))
                (nil)))) -1 (nil))

(insn 65 464 94 ../../gcc/gcc/tree-cfgcleanup.c:697 (set (reg/f:SI 3 %r3 [217])
        (lo_sum:SI (reg/f:SI 1 %r1 [216])
            (symbol_ref:SI ("cfun") [flags 0x240] <var_decl 0xc204e0 cfun>)))
52 {*pa.md:3097} (expr_list:REG_DEAD (reg/f:SI 1 %r1 [216])
        (nil)))

(note 94 65 95 [bb 17] NOTE_INSN_BASIC_BLOCK)

(insn 95 94 435 ../../gcc/gcc/basic-block.h:194 (set (reg:SI 28 %r28 [143])
        (plus:SI (reg/v:SI 4 %r4 [orig:111 i ] [111])
            (const_int 2 [0x2]))) 111 {addsi3} (nil))

(code_label 435 95 96 620 "" [1 uses])

(insn 96 435 97 ../../gcc/gcc/basic-block.h:194 (set (reg/v/f:SI 26 %r26
[orig:110 bb ] [110])
        (mem/s/f/j:SI (plus:SI (mult:SI (reg:SI 28 %r28 [143])
                    (const_int 4 [0x4]))
                (reg/f:SI 26 %r26 [orig:104 iftmp.1903 ] [104])) [0
<variable>.vec S4 A32])) 37 {*pa.md:2542} (expr_list:REG_DEAD (reg:SI 28 %r28
[143])
        (nil)))

(jump_insn 97 96 98 ../../gcc/gcc/tree-cfgcleanup.c:698 (set (pc)
        (if_then_else (eq (reg/v/f:SI 26 %r26 [orig:110 bb ] [110])
                (const_int 0 [0x0]))
            (label_ref 105)
            (pc))) 25 {*pa.md:1770} (expr_list:REG_BR_PROB (const_int 2820
[0xb04])
        (nil)))

(note 98 97 100 [bb 18] NOTE_INSN_BASIC_BLOCK)

(call_insn 100 98 101 ../../gcc/gcc/tree-cfgcleanup.c:699 (parallel [
            (set (reg:SI 28 %r28)
                (call (mem:SI (symbol_ref/v:SI ("@cleanup_tree_cfg_bb") [flags
0x203] <function_decl 0x1564850 cleanup_tree_cfg_bb>) [0 S4 A32])
                    (const_int 16 [0x10])))
            (clobber (reg:SI 1 %r1))
            (clobber (reg:SI 2 %r2))
            (use (const_int 0 [0x0]))
        ]) 212 {call_val_symref} (expr_list:REG_DEAD (reg:SI 26 %r26)
        (expr_list:REG_EH_REGION (const_int 0 [0x0])
            (nil)))
    (expr_list:REG_DEP_TRUE (use (reg:SI 26 %r26))
        (nil)))

(note 101 100 103 NOTE_INSN_DELETED)

So, %r4 is not marked as alive.

Reply via email to