Commit a58a8e4b by Jakub Jelinek Committed by Jakub Jelinek

re PR debug/45882 (No debug info for vars depending on unused parameter)

	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.

From-SVN: r171035
parent 2b1c5433
2011-03-16 Jakub Jelinek <jakub@redhat.com> 2011-03-16 Jakub Jelinek <jakub@redhat.com>
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.
* final.c (final_scan_insn): Handle NOTE_INSN_CALL_ARG_LOCATION. * final.c (final_scan_insn): Handle NOTE_INSN_CALL_ARG_LOCATION.
Call var_location debug hook even on CALL_INSNs. Call var_location debug hook even on CALL_INSNs.
(rest_of_clean_state): Don't print NOTE_INSN_CALL_ARG_LOCATION. (rest_of_clean_state): Don't print NOTE_INSN_CALL_ARG_LOCATION.
......
...@@ -3171,7 +3171,31 @@ expand_debug_expr (tree exp) ...@@ -3171,7 +3171,31 @@ expand_debug_expr (tree exp)
int part = var_to_partition (SA.map, exp); int part = var_to_partition (SA.map, exp);
if (part == NO_PARTITION) if (part == NO_PARTITION)
return NULL; {
/* If this is a reference to an incoming value of parameter
that is never used in the code or where the incoming
value is never used in the code, use PARM_DECL's
DECL_RTL if set. */
if (SSA_NAME_IS_DEFAULT_DEF (exp)
&& TREE_CODE (SSA_NAME_VAR (exp)) == PARM_DECL)
{
rtx incoming = DECL_INCOMING_RTL (SSA_NAME_VAR (exp));
if (incoming
&& GET_MODE (incoming) != BLKmode
&& (REG_P (incoming)
|| (MEM_P (incoming) && REG_P (XEXP (incoming, 0)))))
{
op0 = gen_rtx_ENTRY_VALUE (GET_MODE (incoming));
ENTRY_VALUE_EXP (op0) = incoming;
goto adjust_mode;
}
op0 = expand_debug_expr (SSA_NAME_VAR (exp));
if (!op0)
return NULL;
goto adjust_mode;
}
return NULL;
}
gcc_assert (part >= 0 && (unsigned)part < SA.map->num_partitions); gcc_assert (part >= 0 && (unsigned)part < SA.map->num_partitions);
......
...@@ -803,6 +803,10 @@ rtx_equal_for_cselib_1 (rtx x, rtx y, enum machine_mode memmode) ...@@ -803,6 +803,10 @@ rtx_equal_for_cselib_1 (rtx x, rtx y, enum machine_mode memmode)
return DEBUG_IMPLICIT_PTR_DECL (x) return DEBUG_IMPLICIT_PTR_DECL (x)
== DEBUG_IMPLICIT_PTR_DECL (y); == DEBUG_IMPLICIT_PTR_DECL (y);
case ENTRY_VALUE:
return rtx_equal_for_cselib_1 (ENTRY_VALUE_EXP (x), ENTRY_VALUE_EXP (y),
memmode);
case LABEL_REF: case LABEL_REF:
return XEXP (x, 0) == XEXP (y, 0); return XEXP (x, 0) == XEXP (y, 0);
...@@ -949,6 +953,10 @@ cselib_hash_rtx (rtx x, int create, enum machine_mode memmode) ...@@ -949,6 +953,10 @@ cselib_hash_rtx (rtx x, int create, enum machine_mode memmode)
+ DECL_UID (DEBUG_IMPLICIT_PTR_DECL (x)); + DECL_UID (DEBUG_IMPLICIT_PTR_DECL (x));
return hash ? hash : (unsigned int) DEBUG_IMPLICIT_PTR; return hash ? hash : (unsigned int) DEBUG_IMPLICIT_PTR;
case ENTRY_VALUE:
hash += cselib_hash_rtx (ENTRY_VALUE_EXP (x), create, memmode);
return hash ? hash : (unsigned int) ENTRY_VALUE;
case CONST_INT: case CONST_INT:
hash += ((unsigned) CONST_INT << 7) + INTVAL (x); hash += ((unsigned) CONST_INT << 7) + INTVAL (x);
return hash ? hash : (unsigned int) CONST_INT; return hash ? hash : (unsigned int) CONST_INT;
......
...@@ -14028,14 +14028,14 @@ mem_loc_descriptor (rtx rtl, enum machine_mode mode, ...@@ -14028,14 +14028,14 @@ mem_loc_descriptor (rtx rtl, enum machine_mode mode,
case ENTRY_VALUE: case ENTRY_VALUE:
mem_loc_result = new_loc_descr (DW_OP_GNU_entry_value, 0, 0); mem_loc_result = new_loc_descr (DW_OP_GNU_entry_value, 0, 0);
mem_loc_result->dw_loc_oprnd1.val_class = dw_val_class_loc; mem_loc_result->dw_loc_oprnd1.val_class = dw_val_class_loc;
if (REG_P (XEXP (rtl, 0))) if (REG_P (ENTRY_VALUE_EXP (rtl)))
mem_loc_result->dw_loc_oprnd1.v.val_loc mem_loc_result->dw_loc_oprnd1.v.val_loc
= one_reg_loc_descriptor (dbx_reg_number (XEXP (rtl, 0)), = one_reg_loc_descriptor (dbx_reg_number (ENTRY_VALUE_EXP (rtl)),
VAR_INIT_STATUS_INITIALIZED); VAR_INIT_STATUS_INITIALIZED);
else if (MEM_P (XEXP (rtl, 0)) && REG_P (XEXP (XEXP (rtl, 0), 0))) else if (MEM_P (ENTRY_VALUE_EXP (rtl)) && REG_P (XEXP (ENTRY_VALUE_EXP (rtl), 0)))
{ {
dw_loc_descr_ref ref dw_loc_descr_ref ref
= mem_loc_descriptor (XEXP (rtl, 0), GET_MODE (rtl), = mem_loc_descriptor (ENTRY_VALUE_EXP (rtl), GET_MODE (rtl),
VAR_INIT_STATUS_INITIALIZED); VAR_INIT_STATUS_INITIALIZED);
if (ref == NULL) if (ref == NULL)
return NULL; return NULL;
......
...@@ -1101,6 +1101,8 @@ adjust_field_rtx_def (type_p t, options_p ARG_UNUSED (opt)) ...@@ -1101,6 +1101,8 @@ adjust_field_rtx_def (type_p t, options_p ARG_UNUSED (opt))
t = symbol_union_tp, subname = ""; t = symbol_union_tp, subname = "";
else if (i == BARRIER && aindex >= 3) else if (i == BARRIER && aindex >= 3)
t = scalar_tp, subname = "rt_int"; t = scalar_tp, subname = "rt_int";
else if (i == ENTRY_VALUE && aindex == 0)
t = rtx_tp, subname = "rt_rtx";
else else
{ {
error_at_line error_at_line
......
...@@ -334,6 +334,14 @@ print_rtx (const_rtx in_rtx) ...@@ -334,6 +334,14 @@ print_rtx (const_rtx in_rtx)
DEBUG_TEMP_UID (DEBUG_EXPR_TREE_DECL (in_rtx))); DEBUG_TEMP_UID (DEBUG_EXPR_TREE_DECL (in_rtx)));
#endif #endif
} }
else if (i == 0 && GET_CODE (in_rtx) == ENTRY_VALUE)
{
indent += 2;
if (!sawclose)
fprintf (outfile, " ");
print_rtx (ENTRY_VALUE_EXP (in_rtx));
indent -= 2;
}
break; break;
case 'e': case 'e':
......
/* RTL utility routines. /* RTL utility routines.
Copyright (C) 1987, 1988, 1991, 1994, 1997, 1998, 1999, 2000, 2001, 2002, Copyright (C) 1987, 1988, 1991, 1994, 1997, 1998, 1999, 2000, 2001, 2002,
2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
Free Software Foundation, Inc. Free Software Foundation, Inc.
This file is part of GCC. This file is part of GCC.
...@@ -412,6 +412,9 @@ rtx_equal_p_cb (const_rtx x, const_rtx y, rtx_equal_p_callback_function cb) ...@@ -412,6 +412,9 @@ rtx_equal_p_cb (const_rtx x, const_rtx y, rtx_equal_p_callback_function cb)
return DEBUG_IMPLICIT_PTR_DECL (x) return DEBUG_IMPLICIT_PTR_DECL (x)
== DEBUG_IMPLICIT_PTR_DECL (y); == DEBUG_IMPLICIT_PTR_DECL (y);
case ENTRY_VALUE:
return rtx_equal_p_cb (ENTRY_VALUE_EXP (x), ENTRY_VALUE_EXP (y), cb);
default: default:
break; break;
} }
...@@ -544,6 +547,9 @@ rtx_equal_p (const_rtx x, const_rtx y) ...@@ -544,6 +547,9 @@ rtx_equal_p (const_rtx x, const_rtx y)
return DEBUG_IMPLICIT_PTR_DECL (x) return DEBUG_IMPLICIT_PTR_DECL (x)
== DEBUG_IMPLICIT_PTR_DECL (y); == DEBUG_IMPLICIT_PTR_DECL (y);
case ENTRY_VALUE:
return rtx_equal_p (ENTRY_VALUE_EXP (x), ENTRY_VALUE_EXP (y));
default: default:
break; break;
} }
......
...@@ -718,9 +718,10 @@ DEF_RTL_EXPR(VAR_LOCATION, "var_location", "tei", RTX_EXTRA) ...@@ -718,9 +718,10 @@ DEF_RTL_EXPR(VAR_LOCATION, "var_location", "tei", RTX_EXTRA)
addressable. */ addressable. */
DEF_RTL_EXPR(DEBUG_IMPLICIT_PTR, "debug_implicit_ptr", "t", RTX_OBJ) DEF_RTL_EXPR(DEBUG_IMPLICIT_PTR, "debug_implicit_ptr", "t", RTX_OBJ)
/* Represents value that argument had on function entry. Should /* Represents value that argument had on function entry. The
be only used in VAR_LOCATION location expression. */ single argument is the DECL_INCOMING_RTL of the corresponding
DEF_RTL_EXPR(ENTRY_VALUE, "entry_value", "e", RTX_OBJ) parameter. */
DEF_RTL_EXPR(ENTRY_VALUE, "entry_value", "0", RTX_OBJ)
/* All expressions from this point forward appear only in machine /* All expressions from this point forward appear only in machine
descriptions. */ descriptions. */
......
...@@ -833,6 +833,10 @@ extern void rtl_check_failed_flag (const char *, const_rtx, const char *, ...@@ -833,6 +833,10 @@ extern void rtl_check_failed_flag (const char *, const_rtx, const char *,
but a value from enum reg_note. */ but a value from enum reg_note. */
#define REG_NOTES(INSN) XEXP(INSN, 7) #define REG_NOTES(INSN) XEXP(INSN, 7)
/* In an ENTRY_VALUE this is the DECL_INCOMING_RTL of the argument in
question. */
#define ENTRY_VALUE_EXP(RTX) (RTL_CHECKC1 (RTX, 0, ENTRY_VALUE).rt_rtx)
enum reg_note enum reg_note
{ {
#define DEF_REG_NOTE(NAME) NAME, #define DEF_REG_NOTE(NAME) NAME,
......
2011-03-16 Jakub Jelinek <jakub@redhat.com>
PR debug/45882
* gcc.dg/guality/pr45882.c: New test.
2011-03-15 Jason Merrill <jason@redhat.com> 2011-03-15 Jason Merrill <jason@redhat.com>
* g++.dg/cpp0x/constexpr-recursion.C: New. * g++.dg/cpp0x/constexpr-recursion.C: New.
......
/* PR debug/45882 */
/* { dg-do run } */
/* { dg-options "-g" } */
extern void abort (void);
int a[1024];
volatile short int v;
__attribute__((noinline)) int
foo (int i, int j)
{
int b = i; /* { dg-final { gdb-test 16 "b" "7" } } */
int c = i + 4; /* { dg-final { gdb-test 16 "c" "11" } } */
int d = a[i]; /* { dg-final { gdb-test 16 "d" "112" } } */
int e = a[i + 6]; /* { dg-final { gdb-test 16 "e" "142" } } */
++v;
return ++j;
}
int
main (void)
{
int l;
asm ("" : "=r" (l) : "0" (7));
a[7] = 112;
a[7 + 6] = 142;
if (foo (l, 7) != 8)
abort ();
return l - 7;
}
...@@ -8377,7 +8377,8 @@ vt_add_function_parameter (tree parm) ...@@ -8377,7 +8377,8 @@ vt_add_function_parameter (tree parm)
el = (struct elt_loc_list *) el = (struct elt_loc_list *)
ggc_alloc_cleared_atomic (sizeof (*el)); ggc_alloc_cleared_atomic (sizeof (*el));
el->next = val->locs; el->next = val->locs;
el->loc = gen_rtx_ENTRY_VALUE (GET_MODE (incoming), incoming); el->loc = gen_rtx_ENTRY_VALUE (GET_MODE (incoming));
ENTRY_VALUE_EXP (el->loc) = incoming;
el->setting_insn = get_insns (); el->setting_insn = get_insns ();
val->locs = el; val->locs = el;
if (TREE_CODE (TREE_TYPE (parm)) == REFERENCE_TYPE if (TREE_CODE (TREE_TYPE (parm)) == REFERENCE_TYPE
...@@ -8394,7 +8395,8 @@ vt_add_function_parameter (tree parm) ...@@ -8394,7 +8395,8 @@ vt_add_function_parameter (tree parm)
el = (struct elt_loc_list *) el = (struct elt_loc_list *)
ggc_alloc_cleared_atomic (sizeof (*el)); ggc_alloc_cleared_atomic (sizeof (*el));
el->next = val->locs; el->next = val->locs;
el->loc = gen_rtx_ENTRY_VALUE (indmode, mem); el->loc = gen_rtx_ENTRY_VALUE (indmode);
ENTRY_VALUE_EXP (el->loc) = mem;
el->setting_insn = get_insns (); el->setting_insn = get_insns ();
val->locs = el; val->locs = el;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment