On the attached testcase, b, c, d and e vars unnecessarily don't have any DW_AT_location information in the debug info.
Created attachment 21957 [details] gcc46-pr45882.patch Testcase together with an initial attempt to solve this. Now it is emitted in the expander (as opposed to starting with clobbered value right away) and isn't eaten by delete_trivially_dead_insns. The D#4 DEBUG_INSN is reset during fwprop though, probably because the incoming register isn't considered live on entry when it isn't used anywhere. Wonder if with the entry value patch we couldn't at least replace it by ENTRY_VALUE (rdi) during RTL passes, perhaps then var-tracking could make it back into rdi if rdi value hasn't been modified.
Author: jakub Date: Wed Mar 16 08:35:31 2011 New Revision: 171035 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=171035 Log: PR debug/45882 * rtl.def (ENTRY_VALUE): Change format from "e" to "0". * rtl.h (ENTRY_VALUE_EXP): Define. * rtl.c (rtx_equal_p_cb, rtx_equal_p): Handle ENTRY_VALUE. * cselib.c (rtx_equal_for_cselib_p, cselib_hash_rtx): Likewise. * print-rtl.c (print_rtx): Likewise. * gengtype.c (adjust_field_rtx_def): Likewise. * var-tracking.c (vt_add_function_parameter): Adjust gen_rtx_ENTRY_VALUE uses, use ENTRY_VALUE_EXP macro. * dwarf2out.c (mem_loc_descriptor): Use ENTRY_VALUE_EXP macro. * cfgexpand.c (expand_debug_expr): If a SSA_NAME without partition is a default definition of a PARM_DECL, use ENTRY_VALUE of its DECL_INCOMING_RTL if possible, or its DECL_RTL if set. * gcc.dg/guality/pr45882.c: New test. Added: trunk/gcc/testsuite/gcc.dg/guality/pr45882.c Modified: trunk/gcc/ChangeLog trunk/gcc/cfgexpand.c trunk/gcc/cselib.c trunk/gcc/dwarf2out.c trunk/gcc/gengtype.c trunk/gcc/print-rtl.c trunk/gcc/rtl.c trunk/gcc/rtl.def trunk/gcc/rtl.h trunk/gcc/testsuite/ChangeLog trunk/gcc/var-tracking.c
Fixed for 4.7+.
Jakub, do you remember what this change was necessary for: * rtl.def (ENTRY_VALUE): Change format from "e" to "0". I'm reviewing the "0" fields and I don't understand why ENTRY_VALUE has this "0" instead of "e". Hope you remember :-)
ENTRY_VALUE's operand is 0, because in most cases you don't want to let the various RTL passes to see through the ENTRY_VALUE rtl, they should treat the RTL as a black box, mostly when you want to look at the operand is either for rtx_equal_p and similar functions, or when creating those or when the debug info is emitted from it. If ENTRY_VALUE's operand is e rather than 0, e.g. various RTL passes would consider the there referenced hard register (or memory) to be live at that point, or used, etc., but it actually isn't used.