* [PATCH] Fix -m32 -g -O0 debug info (PR debug/48466)
@ 2011-04-05 22:43 Jakub Jelinek
2011-04-05 23:07 ` Jakub Jelinek
2011-04-06 9:06 ` Richard Guenther
0 siblings, 2 replies; 3+ messages in thread
From: Jakub Jelinek @ 2011-04-05 22:43 UTC (permalink / raw)
To: Jason Merrill, Richard Henderson; +Cc: gcc-patches, hjl.tools
Hi!
On the pr48466.c testcase below on i?86 -m32 -g -O0 we generate wrong debug
info for some of the variables in main. This was caused by PR36977 fix,
crtl->stack_realign_tried is true, but fde->drap_reg is INVALID_REGNUM,
but frame_pointer_rtx is being eliminated to hard_frame_pointer_regnum
rather than stack_pointer_regnum. Fixed by using hfp instead of sp
in that case, the patch is also adding a testcase from PR36977 to make sure
it doesn't regress.
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
2011-04-06 Jakub Jelinek <jakub@redhat.com>
PR debug/48466
* dwarf2out.c (based_loc_descr): If drap_reg is INVALID_REGNUM, use
as base_reg whatever register reg has been eliminated to, instead
of hardcoding STACK_POINTER_REGNUM.
* gcc.dg/guality/pr36977.c: New test.
* gcc.dg/guality/pr48466.c: New test.
--- gcc/dwarf2out.c.jj 2011-04-04 08:56:08.000000000 +0200
+++ gcc/dwarf2out.c 2011-04-05 20:51:53.000000000 +0200
@@ -13383,7 +13383,7 @@ based_loc_descr (rtx reg, HOST_WIDE_INT
int base_reg
= DWARF_FRAME_REGNUM ((fde && fde->drap_reg != INVALID_REGNUM)
? HARD_FRAME_POINTER_REGNUM
- : STACK_POINTER_REGNUM);
+ : REGNO (elim));
return new_reg_loc_descr (base_reg, offset);
}
--- gcc/testsuite/gcc.dg/guality/pr36977.c.jj 2011-04-05 20:39:10.000000000 +0200
+++ gcc/testsuite/gcc.dg/guality/pr36977.c 2011-04-05 20:41:27.000000000 +0200
@@ -0,0 +1,32 @@
+/* PR debug/36977 */
+/* { dg-do run } */
+/* { dg-options "-g" } */
+/* { dg-skip-if "" { *-*-* } { "*" } { "-O0" } } */
+
+void
+foo ()
+{
+}
+
+int
+main ()
+{
+ struct { char c[100]; } cbig;
+ struct { int i[800]; } ibig;
+ struct { long l[900]; } lbig;
+ struct { float f[200]; } fbig;
+ struct { double d[300]; } dbig;
+ struct { short s[400]; } sbig;
+
+ ibig.i[0] = 55; /* { dg-final { gdb-test 30 "ibig.i\[0\]" "55" } } */
+ ibig.i[100] = 5; /* { dg-final { gdb-test 30 "ibig.i\[100\]" "5" } } */
+ cbig.c[0] = '\0'; /* { dg-final { gdb-test 30 "cbig.c\[0\]" "'\\0'" } } */
+ cbig.c[99] = 'A'; /* { dg-final { gdb-test 30 "cbig.c\[99\]" "'A'" } } */
+ fbig.f[100] = 11.0; /* { dg-final { gdb-test 30 "fbig.f\[100\]" "11" } } */
+ dbig.d[202] = 9.0; /* { dg-final { gdb-test 30 "dbig.d\[202\]" "9" } } */
+ sbig.s[90] = 255; /* { dg-final { gdb-test 30 "sbig.s\[90\]" "255" } } */
+ lbig.l[333] = 999; /* { dg-final { gdb-test 30 "lbig.l\[333\]" "999" } } */
+
+ foo ();
+ return 0;
+}
--- gcc/testsuite/gcc.dg/guality/pr48466.c.jj 2011-04-05 20:46:25.000000000 +0200
+++ gcc/testsuite/gcc.dg/guality/pr48466.c 2011-04-05 20:51:29.000000000 +0200
@@ -0,0 +1,41 @@
+/* PR debug/48466 */
+/* { dg-do run } */
+/* { dg-options "-g" } */
+/* { dg-skip-if "" { *-*-* } { "*" } { "-O0" } } */
+
+struct S { unsigned int a; unsigned int *b; };
+struct T { struct S a; struct S b; };
+struct U { const char *u; };
+int n[10];
+volatile int v;
+
+struct U
+foo (const char *s)
+{
+ struct U r;
+ r.u = s;
+ return r;
+}
+
+void
+bar (struct T *s, int a, int b)
+{
+ s->a.a = a;
+ s->a.b = &s->a.a;
+ s->b.a = b;
+ s->b.b = &s->b.a;
+}
+
+int
+main ()
+{
+ struct T t;
+ struct U x = foo ("this is x");
+ struct S y, z;
+ y.b = n; /* { dg-final { gdb-test 38 "t.a.a" "17" } } */
+ y.a = 0; /* { dg-final { gdb-test 38 "*t.a.b" "17" } } */
+ bar (&t, 17, 21); /* { dg-final { gdb-test 38 "t.b.a" "21" } } */
+ v++; /* { dg-final { gdb-test 38 "*t.b.b" "21" } } */
+ z = y;
+ return 0;
+}
Jakub
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Fix -m32 -g -O0 debug info (PR debug/48466)
2011-04-05 22:43 [PATCH] Fix -m32 -g -O0 debug info (PR debug/48466) Jakub Jelinek
@ 2011-04-05 23:07 ` Jakub Jelinek
2011-04-06 9:06 ` Richard Guenther
1 sibling, 0 replies; 3+ messages in thread
From: Jakub Jelinek @ 2011-04-05 23:07 UTC (permalink / raw)
To: Jason Merrill, Richard Henderson; +Cc: gcc-patches, hjl.tools
On Wed, Apr 06, 2011 at 12:43:11AM +0200, Jakub Jelinek wrote:
> On the pr48466.c testcase below on i?86 -m32 -g -O0 we generate wrong debug
> info for some of the variables in main. This was caused by PR36977 fix,
> crtl->stack_realign_tried is true, but fde->drap_reg is INVALID_REGNUM,
> but frame_pointer_rtx is being eliminated to hard_frame_pointer_regnum
> rather than stack_pointer_regnum. Fixed by using hfp instead of sp
> in that case, the patch is also adding a testcase from PR36977 to make sure
> it doesn't regress.
FYI, the difference in between pr36977.c and pr48466.c is that in the
latter emit_call_1 to foo (which returns a struct) sets crtl->need_drap, and
while we don't create any stack realignment in the end because it wasn't
needed, it affected register elimination:
ep->can_eliminate = ep->can_eliminate_previous
= (targetm.can_eliminate (ep->from, ep->to)
&& ! (ep->to == STACK_POINTER_REGNUM
&& frame_pointer_needed
&& (! SUPPORTS_STACK_ALIGNMENT
|| ! stack_realign_fp)));
Jakub
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Fix -m32 -g -O0 debug info (PR debug/48466)
2011-04-05 22:43 [PATCH] Fix -m32 -g -O0 debug info (PR debug/48466) Jakub Jelinek
2011-04-05 23:07 ` Jakub Jelinek
@ 2011-04-06 9:06 ` Richard Guenther
1 sibling, 0 replies; 3+ messages in thread
From: Richard Guenther @ 2011-04-06 9:06 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: Jason Merrill, Richard Henderson, gcc-patches, hjl.tools
On Wed, Apr 6, 2011 at 12:43 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> On the pr48466.c testcase below on i?86 -m32 -g -O0 we generate wrong debug
> info for some of the variables in main. This was caused by PR36977 fix,
> crtl->stack_realign_tried is true, but fde->drap_reg is INVALID_REGNUM,
> but frame_pointer_rtx is being eliminated to hard_frame_pointer_regnum
> rather than stack_pointer_regnum. Fixed by using hfp instead of sp
> in that case, the patch is also adding a testcase from PR36977 to make sure
> it doesn't regress.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
Ok.
Thanks,
Richard.
> 2011-04-06 Jakub Jelinek <jakub@redhat.com>
>
> PR debug/48466
> * dwarf2out.c (based_loc_descr): If drap_reg is INVALID_REGNUM, use
> as base_reg whatever register reg has been eliminated to, instead
> of hardcoding STACK_POINTER_REGNUM.
>
> * gcc.dg/guality/pr36977.c: New test.
> * gcc.dg/guality/pr48466.c: New test.
>
> --- gcc/dwarf2out.c.jj 2011-04-04 08:56:08.000000000 +0200
> +++ gcc/dwarf2out.c 2011-04-05 20:51:53.000000000 +0200
> @@ -13383,7 +13383,7 @@ based_loc_descr (rtx reg, HOST_WIDE_INT
> int base_reg
> = DWARF_FRAME_REGNUM ((fde && fde->drap_reg != INVALID_REGNUM)
> ? HARD_FRAME_POINTER_REGNUM
> - : STACK_POINTER_REGNUM);
> + : REGNO (elim));
> return new_reg_loc_descr (base_reg, offset);
> }
>
> --- gcc/testsuite/gcc.dg/guality/pr36977.c.jj 2011-04-05 20:39:10.000000000 +0200
> +++ gcc/testsuite/gcc.dg/guality/pr36977.c 2011-04-05 20:41:27.000000000 +0200
> @@ -0,0 +1,32 @@
> +/* PR debug/36977 */
> +/* { dg-do run } */
> +/* { dg-options "-g" } */
> +/* { dg-skip-if "" { *-*-* } { "*" } { "-O0" } } */
> +
> +void
> +foo ()
> +{
> +}
> +
> +int
> +main ()
> +{
> + struct { char c[100]; } cbig;
> + struct { int i[800]; } ibig;
> + struct { long l[900]; } lbig;
> + struct { float f[200]; } fbig;
> + struct { double d[300]; } dbig;
> + struct { short s[400]; } sbig;
> +
> + ibig.i[0] = 55; /* { dg-final { gdb-test 30 "ibig.i\[0\]" "55" } } */
> + ibig.i[100] = 5; /* { dg-final { gdb-test 30 "ibig.i\[100\]" "5" } } */
> + cbig.c[0] = '\0'; /* { dg-final { gdb-test 30 "cbig.c\[0\]" "'\\0'" } } */
> + cbig.c[99] = 'A'; /* { dg-final { gdb-test 30 "cbig.c\[99\]" "'A'" } } */
> + fbig.f[100] = 11.0; /* { dg-final { gdb-test 30 "fbig.f\[100\]" "11" } } */
> + dbig.d[202] = 9.0; /* { dg-final { gdb-test 30 "dbig.d\[202\]" "9" } } */
> + sbig.s[90] = 255; /* { dg-final { gdb-test 30 "sbig.s\[90\]" "255" } } */
> + lbig.l[333] = 999; /* { dg-final { gdb-test 30 "lbig.l\[333\]" "999" } } */
> +
> + foo ();
> + return 0;
> +}
> --- gcc/testsuite/gcc.dg/guality/pr48466.c.jj 2011-04-05 20:46:25.000000000 +0200
> +++ gcc/testsuite/gcc.dg/guality/pr48466.c 2011-04-05 20:51:29.000000000 +0200
> @@ -0,0 +1,41 @@
> +/* PR debug/48466 */
> +/* { dg-do run } */
> +/* { dg-options "-g" } */
> +/* { dg-skip-if "" { *-*-* } { "*" } { "-O0" } } */
> +
> +struct S { unsigned int a; unsigned int *b; };
> +struct T { struct S a; struct S b; };
> +struct U { const char *u; };
> +int n[10];
> +volatile int v;
> +
> +struct U
> +foo (const char *s)
> +{
> + struct U r;
> + r.u = s;
> + return r;
> +}
> +
> +void
> +bar (struct T *s, int a, int b)
> +{
> + s->a.a = a;
> + s->a.b = &s->a.a;
> + s->b.a = b;
> + s->b.b = &s->b.a;
> +}
> +
> +int
> +main ()
> +{
> + struct T t;
> + struct U x = foo ("this is x");
> + struct S y, z;
> + y.b = n; /* { dg-final { gdb-test 38 "t.a.a" "17" } } */
> + y.a = 0; /* { dg-final { gdb-test 38 "*t.a.b" "17" } } */
> + bar (&t, 17, 21); /* { dg-final { gdb-test 38 "t.b.a" "21" } } */
> + v++; /* { dg-final { gdb-test 38 "*t.b.b" "21" } } */
> + z = y;
> + return 0;
> +}
>
> Jakub
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-04-06 9:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-05 22:43 [PATCH] Fix -m32 -g -O0 debug info (PR debug/48466) Jakub Jelinek
2011-04-05 23:07 ` Jakub Jelinek
2011-04-06 9:06 ` Richard Guenther
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).