diff mbox

Fix a RTL sharing problem caused in VTA expansion (PR debug/47780)

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

Commit Message

Jakub Jelinek Feb. 17, 2011, 7:49 p.m. UTC
Hi!

This testcase ICEs on x86_64-linux because a VAR_LOCATION
second argument is sharing RTL with DECL_RTL of a temporary
var that is neither in cfun->local_decls nor in BLOCKs.
With -g virtual regs are instantiated in the MEM, because of
the reference from a DEBUG_INSN's VAR_LOCATION, for -g0
it isn't instantiated and therefore aliasing gives different results
during GCSE.
The sharing is definitely incorrect, so fixed thusly, bootstrapped/regtested
on x86_64-linux and i686-linux, ok for trunk?

2011-02-17  Jakub Jelinek  <jakub@redhat.com>

	PR debug/47780
	* cfgexpand.c (expand_debug_expr) <case SSA_NAME>: Call copy_rtx to
	avoid invalid rtx sharing.

	* gcc.target/i386/pr47780.c: New test.


	Jakub

Comments

Richard Biener Feb. 18, 2011, 9:47 a.m. UTC | #1
On Thu, Feb 17, 2011 at 8:49 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> This testcase ICEs on x86_64-linux because a VAR_LOCATION
> second argument is sharing RTL with DECL_RTL of a temporary
> var that is neither in cfun->local_decls nor in BLOCKs.
> With -g virtual regs are instantiated in the MEM, because of
> the reference from a DEBUG_INSN's VAR_LOCATION, for -g0
> it isn't instantiated and therefore aliasing gives different results
> during GCSE.
> The sharing is definitely incorrect, so fixed thusly, bootstrapped/regtested
> on x86_64-linux and i686-linux, ok for trunk?

Ok.

Thanks,
Richard.

> 2011-02-17  Jakub Jelinek  <jakub@redhat.com>
>
>        PR debug/47780
>        * cfgexpand.c (expand_debug_expr) <case SSA_NAME>: Call copy_rtx to
>        avoid invalid rtx sharing.
>
>        * gcc.target/i386/pr47780.c: New test.
>
> --- gcc/cfgexpand.c.jj  2011-02-16 13:57:25.000000000 +0100
> +++ gcc/cfgexpand.c     2011-02-17 17:15:04.000000000 +0100
> @@ -3134,7 +3134,7 @@ expand_debug_expr (tree exp)
>
>            gcc_assert (part >= 0 && (unsigned)part < SA.map->num_partitions);
>
> -           op0 = SA.partition_to_pseudo[part];
> +           op0 = copy_rtx (SA.partition_to_pseudo[part]);
>          }
>        goto adjust_mode;
>       }
> --- gcc/testsuite/gcc.target/i386/pr47780.c.jj  2011-02-17 17:22:23.000000000 +0100
> +++ gcc/testsuite/gcc.target/i386/pr47780.c     2011-02-17 17:23:35.000000000 +0100
> @@ -0,0 +1,14 @@
> +/* PR debug/47780 */
> +/* { dg-do compile } */
> +/* { dg-options "-O -fgcse -fgcse-las -fstack-protector-all -fno-tree-ccp -fno-tree-dominator-opts -fcompare-debug -Wno-psabi" } */
> +
> +typedef int V2SF __attribute__ ((vector_size (128)));
> +
> +V2SF
> +foo (int x, V2SF a)
> +{
> +  V2SF b = a + (V2SF) {};
> +  while (x--)
> +    a += b;
> +  return a;
> +}
>
>        Jakub
>
diff mbox

Patch

--- gcc/cfgexpand.c.jj	2011-02-16 13:57:25.000000000 +0100
+++ gcc/cfgexpand.c	2011-02-17 17:15:04.000000000 +0100
@@ -3134,7 +3134,7 @@  expand_debug_expr (tree exp)
 
 	    gcc_assert (part >= 0 && (unsigned)part < SA.map->num_partitions);
 
-	    op0 = SA.partition_to_pseudo[part];
+	    op0 = copy_rtx (SA.partition_to_pseudo[part]);
 	  }
 	goto adjust_mode;
       }
--- gcc/testsuite/gcc.target/i386/pr47780.c.jj	2011-02-17 17:22:23.000000000 +0100
+++ gcc/testsuite/gcc.target/i386/pr47780.c	2011-02-17 17:23:35.000000000 +0100
@@ -0,0 +1,14 @@ 
+/* PR debug/47780 */
+/* { dg-do compile } */
+/* { dg-options "-O -fgcse -fgcse-las -fstack-protector-all -fno-tree-ccp -fno-tree-dominator-opts -fcompare-debug -Wno-psabi" } */
+
+typedef int V2SF __attribute__ ((vector_size (128)));
+
+V2SF
+foo (int x, V2SF a)
+{
+  V2SF b = a + (V2SF) {};
+  while (x--)
+    a += b;
+  return a;
+}