PR41343 testcase lead me to look at 3 small testcases showing VTA throwing
debug info on the floor (-gdwarf-4 -O2 in all cases):
int
foo (int i, int j)
{
int i1 = 2 * i;
int i2 = 3 * i;
return j;
}
Above is a problem already during RTL expansion, SSA_NAME i_1 (of PARM_DECL i,
with GIMPLE_NOP in SSA_NAME_DEF_STMT) is expanded to NULL by expand_debug_expr,
because var_to_partition returns NO_PARTITION for it. I think we could special
case the initial SSA_NAMEs of parameters and expand them as the parameters.
int i = 1, j;
int
foo (void)
{
int i1 = 2 * i;
int i2 = 3 * i;
return j;
}
In this case we emit i2 debug info correctly:
.byte 0x3 # DW_OP_addr
.quad i
.byte 0x6 # DW_OP_deref
.byte 0x33 # DW_OP_lit3
.byte 0x1e # DW_OP_mul
.byte 0x9f # DW_OP_stack_value
.byte 0x93 # DW_OP_piece
.uleb128 0x4
but i1 is lost (has empty location list). In *.compgotos things look still
good to me:
(debug_insn 5 2 6 2 d.c:6 (var_location:SI i1 (mult:SI (mem/c/i:SI
(symbol_ref:DI ("i") [flags 0x2] <var_decl 0x7f36e4772820 i>) [2 i+0 S4 A32])
(const_int 2 [0x2]))) -1 (nil))
(debug_insn 6 5 12 2 d.c:7 (var_location:SI i2 (mult:SI (mem/c/i:SI
(symbol_ref:DI ("i") [flags 0x2] <var_decl 0x7f36e4772820 i>) [2 i+0 S4 A32])
(const_int 3 [0x3]))) -1 (nil))
are the only places where i1 and i2 are mentioned. But var-tracking messes it
up:
(note 24 2 23 2 (var_location i1 (expr_list:REG_DEP_TRUE (ashift:SI (mem/c/i:SI
(symbol_ref:DI ("i") [flags 0x2] <var_decl 0x7f36e4772820 i>) [2 i+0 S4 A32])
(const_int 1 [0x1]))
(const_int 0 [0x0]))) NOTE_INSN_VAR_LOCATION)
(note 23 24 25 2 (var_location i1 (nil)) NOTE_INSN_VAR_LOCATION)
(note 25 23 12 2 (var_location i2 (expr_list:REG_DEP_TRUE (mult:SI (mem/c/i:SI
(symbol_ref:DI ("i") [flags 0x2] <var_decl 0x7f36e4772820 i>) [2 i+0 S4 A32])
(const_int 3 [0x3]))
(const_int 0 [0x0]))) NOTE_INSN_VAR_LOCATION)
(note the second i1 note).
And my last testcase is:
int i, j;
int
foo (void)
{
int i1 = 2 * i;
int i2 = 3 * i;
return j;
}
Here info is dropped at RTL expansion time, as the VAR_DECL doesn't have RTL
set yet during the expansion. It is common though, so it will be emitted in
the current TU anyway. Another case would be extern int i, j; where it is
questionable if the debug info should reference an external variable which
wouldn't be mentioned anywhere in the TU.
--
Summary: VTA missed-debug issues
Product: gcc
Version: 4.5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: debug
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: jakub at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41353