/* { dg-do run } */ /* { dg-options "-g" } */ #include "../nop.h" int main () { int a[] = { 1, 2, 3 }; /* { dg-final { gdb-test 12 "a\[1\]" "2" } } */ int *p = a + 2; /* { dg-final { gdb-test 12 "a\[2\]" "3" } } */ int *q = a + 1; /* { dg-final { gdb-test 12 "*p" "3" } } */ asm volatile ("NOP"); /* { dg-final { gdb-test 12 "*q" "2" } } */ *p += 10; /* { dg-final { gdb-test 16 "a\[1\]" "2" } } */ /* { dg-final { gdb-test 16 "a\[2\]" "13" } } */ /* { dg-final { gdb-test 16 "*p" "13" } } */ asm volatile ("NOP"); /* { dg-final { gdb-test 16 "*q" "2" } } */ *q += 10; /* { dg-final { gdb-test 20 "a\[1\]" "12" } } */ /* { dg-final { gdb-test 20 "a\[2\]" "13" } } */ /* { dg-final { gdb-test 20 "*p" "13" } } */ asm volatile ("NOP"); /* { dg-final { gdb-test 20 "*q" "12" } } */ return 0; } fails, apparently because we have # DEBUG p => &MEM[(void *)&a + 8B] and we fail to expand that as (plus (debug_implicit_ptr a) (const_int 8)). The reason for that is that we don't want (mem (debug_implicit_ptr x)) to appear in debug insns, that confuses aliasing. When expanding &a, we expand it as DEBUG_IMPLICIT_PTR, but when returning to MEM, we return NULL, as that is not appropriate thing to construct.
Created attachment 28478 [details] gcc48-pr54970.patch Untested fix.
Created attachment 28479 [details] gcc48-pr54970.patch The testcase still fails with -m32 -Os, the problem is that DECL_DEBUG_EXPR isn't created for the replacements in that case. This patch adds needed tree-sra.c and var-tracking.c/dwarf2out.c changes to handle MEM_REFs with ADDR_EXPR in it too.
Author: jakub Date: Fri Oct 26 19:19:25 2012 New Revision: 192860 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=192860 Log: 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. Added: trunk/gcc/testsuite/gcc.dg/guality/pr54970.c Modified: trunk/gcc/ChangeLog trunk/gcc/cfgexpand.c trunk/gcc/dwarf2out.c trunk/gcc/testsuite/ChangeLog trunk/gcc/tree-sra.c trunk/gcc/var-tracking.c
Author: jakub Date: Mon Nov 5 14:36:47 2012 New Revision: 193162 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=193162 Log: PR debug/54970 PR debug/54971 * gcc.dg/guality/pr54970.c: Use NOP instead of "NOP" in inline-asm. Modified: trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/gcc.dg/guality/pr54970.c
Fixed.
This test case fails on powerpc64 with fc18. The *p and *q stores are optimized away.
The stores are of course optimized away, everywhere, that is the point of the testcase. The problems that cause the debug info to be insufficient on some targets are tracked e.g. in http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54971#c13 There is no point to keep this PR open for that.
(In reply to comment #7) > The stores are of course optimized away, everywhere, that is the point > of the testcase. I am talking about the debug_stmts for the stores, sorry if that was not clear. On x86_64 the test case passes, but on powerpc64 esra does something it doesn't do on x86_64 and it makes the test case fail. Is there a known bug for that already, also? This is 176 FAILs on powerpc64. If it's "supposed to not work" there, then the test case should be XFAIL'ed there.