Bug 45882 - No debug info for vars depending on unused parameter
Summary: No debug info for vars depending on unused parameter
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: debug (show other bugs)
Version: 4.6.0
: P3 normal
Target Milestone: 4.7.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-04 15:12 UTC by Jakub Jelinek
Modified: 2013-04-01 18:11 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
gcc46-pr45882.patch (3.04 KB, patch)
2010-10-04 15:28 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jakub Jelinek 2010-10-04 15:12:49 UTC
On the attached testcase, b, c, d and e vars unnecessarily don't have any DW_AT_location information in the debug info.
Comment 1 Jakub Jelinek 2010-10-04 15:28:58 UTC
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.
Comment 2 Jakub Jelinek 2011-03-16 08:35:41 UTC
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
Comment 3 Jakub Jelinek 2012-11-08 20:43:54 UTC
Fixed for 4.7+.
Comment 4 Steven Bosscher 2013-04-01 16:39:05 UTC
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 :-)
Comment 5 Jakub Jelinek 2013-04-01 18:11:07 UTC
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.