[Bug debug/43150] Proper debug info for debugging VLAs

jakub at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Tue Feb 23 14:09:00 GMT 2010



------- Comment #2 from jakub at gcc dot gnu dot org  2010-02-23 14:08 -------
I see some VTA bugs and missed debug optimizations though:
1) in f1 say -O2 -m64 -g we have in *.alignments:
(debug_insn 7 14 8 2 vla-1.c:15 (var_location:DI D#2 (sign_extend:DI (plus:SI
(reg/v:SI 5 di [orig:62 i ] [62])
            (const_int 1 [0x1])))) -1 (nil))
(debug_insn 8 7 9 2 vla-1.c:15 (var_location:DI D#1 (plus:DI (debug_expr:DI
D#2)
        (const_int -1 [0xffffffffffffffff]))) -1 (nil))
(debug_insn 9 8 10 2 vla-1.c:15 (var_location:DI D.2753 (debug_expr:DI D#1)) -1
(nil))
(insn:TI 10 9 33 2 vla-1.c:15 (parallel [
            (set (reg:SI 5 di [63])
                (plus:SI (reg/v:SI 5 di [orig:62 i ] [62])
                    (const_int 1 [0x1])))
            (clobber (reg:CC 17 flags))
        ]) 251 {*addsi_1} (expr_list:REG_UNUSED (reg:CC 17 flags)
        (nil)))
var-tracking.c generates from this:
(note 42 14 43 2 (var_location i (expr_list:REG_DEP_TRUE (reg:SI 5 di [ i ])
    (const_int 0 [0x0]))) NOTE_INSN_VAR_LOCATION)
(note 43 42 10 2 (var_location D.2753 (expr_list:REG_DEP_TRUE (plus:DI
(sign_extend:DI (plus:SI (reg:SI 5 di [ i ])
                (const_int 1 [0x1])))
        (const_int -1 [0xffffffffffffffff]))
    (const_int 0 [0x0]))) NOTE_INSN_VAR_LOCATION)
(insn:TI 10 43 44 2 vla-1.c:15 (parallel [
            (set (reg:SI 5 di [63])
                (plus:SI (reg/v:SI 5 di [orig:62 i ] [62])
                    (const_int 1 [0x1])))
            (clobber (reg:CC 17 flags))
        ]) 251 {*addsi_1} (expr_list:REG_UNUSED (reg:CC 17 flags)
        (nil)))
(note 44 10 33 2 (var_location i (nil)) NOTE_INSN_VAR_LOCATION)

but no further var_location note for D.2753.  This is correct on the first insn
in the function (both i has value 5 and sizeof (a) is 6), but after that insn i
is unfortunately <optimized out> and sizeof (a) is incorrect (7).  Wonder why
var-tracking hasn't noticed that the value D.2753 is based on has changed. 
And, ideally, perhaps we could undo constant additions to values and subtract 1
in the debug insns (i.e. say that after the first insn i is in %rdi - 1 and
D.2753 is sext (%rdi) - 1.

2) another issue I've noticed on redhat/gcc-4_4-branch, not sure if it is
relevant to the trunk too on another testcase.  In f2 with -O2 -g -m64 we have
in *.ce3 (which looks correct):
(insn 2 53 3 2 vla-1.c:22 (set (reg/v:SI 41 r12 [orig:61 i ] [61])
        (reg:SI 5 di [ i ])) 47 {*movsi_1} (expr_list:REG_DEAD (reg:SI 5 di [ i
])
        (nil)))
(note 3 2 6 2 NOTE_INSN_FUNCTION_BEG)
(debug_insn 6 3 7 2 vla-1.c:23 (var_location:SI D.4294967290 (plus:SI (mult:SI
(reg/v:SI 41 r12 [orig:61 i ] [61])
            (const_int 2 [0x2]))
        (const_int 7 [0x7]))) -1 (nil))
(debug_insn 7 6 8 2 vla-1.c:23 (var_location:DI D.4294967292 (sign_extend:DI
(debug_expr:SI D#6))) -1 (nil))
(debug_insn 8 7 9 2 vla-1.c:23 (var_location:DI D.4294967293 (plus:DI
(debug_expr:DI D#4)
        (const_int -1 [0xffffffffffffffff]))) -1 (nil))   
(debug_insn 9 8 10 2 vla-1.c:23 (var_location:DI D.1619 (debug_expr:DI D#3)) -1
(nil))
(note 10 9 46 2 NOTE_INSN_DELETED)
(insn 46 10 12 2 vla-1.c:23 (set (reg:SI 0 ax [63])
        (subreg:SI (plus:DI (mult:DI (reg:DI 41 r12 [orig:61 i ] [61])
                    (const_int 2 [0x2]))
                (const_int 7 [0x7])) 0)) 271 {*lea_1_rex64} (nil))
but then *.cprop_hardreg breaks it up:
(insn 2 53 3 2 vla-1.c:22 (set (reg/v:SI 41 r12 [orig:61 i ] [61])
        (reg:SI 5 di [ i ])) 47 {*movsi_1} (expr_list:REG_DEAD (reg:SI 5 di [ i
])
        (nil)))
(note 3 2 6 2 NOTE_INSN_FUNCTION_BEG)
(debug_insn 6 3 7 2 vla-1.c:23 (var_location:SI D.4294967290 (plus:SI (mult:SI
(reg:SI 5 di [orig:61 i ] [61])
            (const_int 2 [0x2]))
        (const_int 7 [0x7]))) -1 (nil))
(debug_insn 7 6 8 2 vla-1.c:23 (var_location:DI D.4294967292 (sign_extend:DI
(debug_expr:SI D#6))) -1 (nil))
(debug_insn 8 7 9 2 vla-1.c:23 (var_location:DI D.4294967293 (plus:DI
(debug_expr:DI D#4)
        (const_int -1 [0xffffffffffffffff]))) -1 (nil))
(debug_insn 9 8 10 2 vla-1.c:23 (var_location:DI D.1619 (debug_expr:DI D#3)) -1
(nil))
(note 10 9 46 2 NOTE_INSN_DELETED)
(insn 46 10 12 2 vla-1.c:23 (set (reg:SI 0 ax [63])
        (subreg:SI (plus:DI (mult:DI (reg:DI 41 r12 [orig:61 i ] [61])
                    (const_int 2 [0x2]))
                (const_int 7 [0x7])) 0)) 271 {*lea_1_rex64} (nil))
(while %rdi is equal to %r12 at that point, %rdi is REG_DEAD in an earlier
insn, so extending lifetime of that into a DEBUG_INSN after it leads to a
resetting of debug_insn 6 during sched2.  I believe we need to make sure we
don't extend lifetime of hard regs in debug insns during cprop_hardreg.


-- 


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



More information about the Gcc-bugs mailing list