Commit 9430b7ba by Jakub Jelinek Committed by Jakub Jelinek

re PR debug/54970 (Missing DW_OP_GNU_implicit_pointer in debuginfo)

	PR debug/54970
	* cfgexpand.c (expand_debug_expr): Expand &MEM_REF[&var, n]
	as DEBUG_IMPLICIT_PTR + n if &var expands to DEBUG_IMPLICIT_PTR.
	* tree-sra.c (create_access_replacement): Allow also MEM_REFs
	with ADDR_EXPR first operand in DECL_DEBUG_EXPR expressions.
	* var-tracking.c (track_expr_p): Handle MEM_REFs in DECL_DEBUG_EXPR
	expressions.
	* dwarf2out.c (add_var_loc_to_decl): Likewise.

	PR debug/54971
	* gcc.dg/guality/pr54970.c: New test.

From-SVN: r192860
parent c88538b7
2012-10-26 Jakub Jelinek <jakub@redhat.com>
PR debug/54970
* cfgexpand.c (expand_debug_expr): Expand &MEM_REF[&var, n]
as DEBUG_IMPLICIT_PTR + n if &var expands to DEBUG_IMPLICIT_PTR.
* tree-sra.c (create_access_replacement): Allow also MEM_REFs
with ADDR_EXPR first operand in DECL_DEBUG_EXPR expressions.
* var-tracking.c (track_expr_p): Handle MEM_REFs in DECL_DEBUG_EXPR
expressions.
* dwarf2out.c (add_var_loc_to_decl): Likewise.
2012-10-26 Jeff Law <law@redhat.com> 2012-10-26 Jeff Law <law@redhat.com>
* tree-ssa-threadedge.c (cond_arg_set_in_bb): Use last stmt. * tree-ssa-threadedge.c (cond_arg_set_in_bb): Use last stmt.
...@@ -3284,6 +3284,27 @@ expand_debug_expr (tree exp) ...@@ -3284,6 +3284,27 @@ expand_debug_expr (tree exp)
} }
} }
if (TREE_CODE (TREE_OPERAND (exp, 0)) == MEM_REF
&& TREE_CODE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0))
== ADDR_EXPR)
{
op0 = expand_debug_expr (TREE_OPERAND (TREE_OPERAND (exp, 0),
0));
if (op0 != NULL
&& (GET_CODE (op0) == DEBUG_IMPLICIT_PTR
|| (GET_CODE (op0) == PLUS
&& GET_CODE (XEXP (op0, 0)) == DEBUG_IMPLICIT_PTR
&& CONST_INT_P (XEXP (op0, 1)))))
{
op1 = expand_debug_expr (TREE_OPERAND (TREE_OPERAND (exp, 0),
1));
if (!op1 || !CONST_INT_P (op1))
return NULL;
return plus_constant (mode, op0, INTVAL (op1));
}
}
return NULL; return NULL;
} }
......
...@@ -4622,7 +4622,10 @@ add_var_loc_to_decl (tree decl, rtx loc_note, const char *label) ...@@ -4622,7 +4622,10 @@ add_var_loc_to_decl (tree decl, rtx loc_note, const char *label)
if (DECL_DEBUG_EXPR_IS_FROM (decl)) if (DECL_DEBUG_EXPR_IS_FROM (decl))
{ {
tree realdecl = DECL_DEBUG_EXPR (decl); tree realdecl = DECL_DEBUG_EXPR (decl);
if (realdecl && handled_component_p (realdecl)) if (realdecl
&& (handled_component_p (realdecl)
|| (TREE_CODE (realdecl) == MEM_REF
&& TREE_CODE (TREE_OPERAND (realdecl, 0)) == ADDR_EXPR)))
{ {
HOST_WIDE_INT maxsize; HOST_WIDE_INT maxsize;
tree innerdecl; tree innerdecl;
......
2012-10-26 Jakub Jelinek <jakub@redhat.com>
PR debug/54970
PR debug/54971
* gcc.dg/guality/pr54970.c: New test.
2012-10-26 Paolo Carlini <paolo.carlini@oracle.com> 2012-10-26 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/54984 PR c++/54984
......
/* PR debug/54970 */
/* PR debug/54971 */
/* { dg-do run } */
/* { dg-options "-g" } */
#include "../nop.h"
int
main ()
{
int a[] = { 1, 2, 3 }; /* { dg-final { gdb-test 15 "a\[0\]" "1" } } */
int *p = a + 2; /* { dg-final { gdb-test 15 "a\[1\]" "2" } } */
int *q = a + 1; /* { dg-final { gdb-test 15 "a\[2\]" "3" } } */
/* { dg-final { gdb-test 15 "*p" "3" } } */
asm volatile ("NOP"); /* { dg-final { gdb-test 15 "*q" "2" } } */
*p += 10; /* { dg-final { gdb-test 20 "a\[0\]" "1" } } */
/* { dg-final { gdb-test 20 "a\[1\]" "2" } } */
/* { dg-final { gdb-test 20 "a\[2\]" "13" } } */
/* { dg-final { gdb-test 20 "*p" "13" } } */
asm volatile ("NOP"); /* { dg-final { gdb-test 20 "*q" "2" } } */
*q += 10; /* { dg-final { gdb-test 25 "a\[0\]" "1" } } */
/* { dg-final { gdb-test 25 "a\[1\]" "12" } } */
/* { dg-final { gdb-test 25 "a\[2\]" "13" } } */
/* { dg-final { gdb-test 25 "*p" "13" } } */
asm volatile ("NOP"); /* { dg-final { gdb-test 25 "*q" "12" } } */
__builtin_memcpy (&a, (int [3]) { 4, 5, 6 }, sizeof (a));
/* { dg-final { gdb-test 31 "a\[0\]" "4" } } */
/* { dg-final { gdb-test 31 "a\[1\]" "5" } } */
/* { dg-final { gdb-test 31 "a\[2\]" "6" } } */
/* { dg-final { gdb-test 31 "*p" "6" } } */
asm volatile ("NOP"); /* { dg-final { gdb-test 31 "*q" "5" } } */
*p += 20; /* { dg-final { gdb-test 36 "a\[0\]" "4" } } */
/* { dg-final { gdb-test 36 "a\[1\]" "5" } } */
/* { dg-final { gdb-test 36 "a\[2\]" "26" } } */
/* { dg-final { gdb-test 36 "*p" "26" } } */
asm volatile ("NOP"); /* { dg-final { gdb-test 36 "*q" "5" } } */
*q += 20; /* { dg-final { gdb-test 45 "a\[0\]" "4" } } */
/* { dg-final { gdb-test 45 "a\[1\]" "25" } } */
/* { dg-final { gdb-test 45 "a\[2\]" "26" } } */
/* { dg-final { gdb-test 45 "*p" "26" } } */
/* { dg-final { gdb-test 45 "p\[-1\]" "25" } } */
/* { dg-final { gdb-test 45 "p\[-2\]" "4" } } */
/* { dg-final { gdb-test 45 "q\[-1\]" "4" } } */
/* { dg-final { gdb-test 45 "q\[1\]" "26" } } */
asm volatile ("NOP"); /* { dg-final { gdb-test 45 "*q" "25" } } */
return 0;
}
/* Scalar Replacement of Aggregates (SRA) converts some structure /* Scalar Replacement of Aggregates (SRA) converts some structure
references into scalar references, exposing them to the scalar references into scalar references, exposing them to the scalar
optimizers. optimizers.
Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc. Copyright (C) 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
Contributed by Martin Jambor <mjambor@suse.cz> Contributed by Martin Jambor <mjambor@suse.cz>
This file is part of GCC. This file is part of GCC.
...@@ -1941,7 +1941,8 @@ create_access_replacement (struct access *access) ...@@ -1941,7 +1941,8 @@ create_access_replacement (struct access *access)
and that get_ref_base_and_extent works properly on the and that get_ref_base_and_extent works properly on the
expression. It cannot handle accesses at a non-constant offset expression. It cannot handle accesses at a non-constant offset
though, so just give up in those cases. */ though, so just give up in those cases. */
for (d = debug_expr; !fail && handled_component_p (d); for (d = debug_expr;
!fail && (handled_component_p (d) || TREE_CODE (d) == MEM_REF);
d = TREE_OPERAND (d, 0)) d = TREE_OPERAND (d, 0))
switch (TREE_CODE (d)) switch (TREE_CODE (d))
{ {
...@@ -1959,6 +1960,12 @@ create_access_replacement (struct access *access) ...@@ -1959,6 +1960,12 @@ create_access_replacement (struct access *access)
&& TREE_CODE (TREE_OPERAND (d, 2)) != INTEGER_CST) && TREE_CODE (TREE_OPERAND (d, 2)) != INTEGER_CST)
fail = true; fail = true;
break; break;
case MEM_REF:
if (TREE_CODE (TREE_OPERAND (d, 0)) != ADDR_EXPR)
fail = true;
else
d = TREE_OPERAND (d, 0);
break;
default: default:
break; break;
} }
......
...@@ -4921,7 +4921,9 @@ track_expr_p (tree expr, bool need_rtl) ...@@ -4921,7 +4921,9 @@ track_expr_p (tree expr, bool need_rtl)
realdecl = expr; realdecl = expr;
else if (!DECL_P (realdecl)) else if (!DECL_P (realdecl))
{ {
if (handled_component_p (realdecl)) if (handled_component_p (realdecl)
|| (TREE_CODE (realdecl) == MEM_REF
&& TREE_CODE (TREE_OPERAND (realdecl, 0)) == ADDR_EXPR))
{ {
HOST_WIDE_INT bitsize, bitpos, maxsize; HOST_WIDE_INT bitsize, bitpos, maxsize;
tree innerdecl tree innerdecl
......
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