diff mbox

Fix debuginfo after tree_nrv

Message ID 20100705193215.GD28610@tyan-ft48-01.lab.bos.redhat.com
State New
Headers show

Commit Message

Jakub Jelinek July 5, 2010, 7:32 p.m. UTC
Hi!

As noted by Honza, tree_nrv doesn't play very well with debuginfo (the
optimized away variable has no location).

This patch fixes it, bootstrapped/regtested on x86_64-linux and i686-linux. 
Ok for trunk?

2010-07-05  Jakub Jelinek  <jakub@redhat.com>

	* tree-nrv.c (tree_nrv): Set DECL_VALUE_EXPR on found to result.

	* gcc.dg/guality/nrv-1.c: New test.


	Jakub

Comments

Diego Novillo July 5, 2010, 7:36 p.m. UTC | #1
On Mon, Jul 5, 2010 at 19:32, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> As noted by Honza, tree_nrv doesn't play very well with debuginfo (the
> optimized away variable has no location).
>
> This patch fixes it, bootstrapped/regtested on x86_64-linux and i686-linux.
> Ok for trunk?
>
> 2010-07-05  Jakub Jelinek  <jakub@redhat.com>
>
>        * tree-nrv.c (tree_nrv): Set DECL_VALUE_EXPR on found to result.
>
>        * gcc.dg/guality/nrv-1.c: New test.

OK.


Diego.
Andrew Pinski July 6, 2010, 2:49 a.m. UTC | #2
On Mon, Jul 5, 2010 at 12:32 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> As noted by Honza, tree_nrv doesn't play very well with debuginfo (the
> optimized away variable has no location).

I think this fixes PR44731.  According to the bug report this is a
regression too.

Thanks,
Andrew Pinski
diff mbox

Patch

--- gcc/tree-nrv.c.jj	2010-06-07 11:25:05.000000000 +0200
+++ gcc/tree-nrv.c	2010-07-05 18:37:44.000000000 +0200
@@ -259,6 +259,9 @@  tree_nrv (void)
 	}
     }
 
+  SET_DECL_VALUE_EXPR (found, result);
+  DECL_HAS_VALUE_EXPR_P (found) = 1;
+
   /* FOUND is no longer used.  Ensure it gets removed.  */
   var_ann (found)->used = 0;
   return 0;
--- gcc/testsuite/gcc.dg/guality/nrv-1.c.jj	2010-07-05 18:29:31.000000000 +0200
+++ gcc/testsuite/gcc.dg/guality/nrv-1.c	2010-07-05 18:36:48.000000000 +0200
@@ -0,0 +1,29 @@ 
+/* { dg-do run } */
+/* { dg-options "-g -fno-tree-sra" } */
+
+void abort (void);
+
+struct A
+{
+  int i[100];
+};
+
+struct A a1, a3;
+
+__attribute__((noinline)) struct A
+f ()
+{
+  struct A a2;
+  a2.i[0] = 42;
+  if (a3.i[0] != 0)
+    abort ();
+  a2.i[4] = 7;	/* { dg-final { gdb-test 20 "a2.i\[0\]" "42" } } */
+  return a2;
+}
+
+int
+main ()
+{
+  a1 = f ();
+  return 0;
+}