public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, PR 46734, 4.5, 4.6] No TREE_ADDRESSIBLE types conversion in IPA-SRA
@ 2010-12-09 11:29 Martin Jambor
  2010-12-09 12:49 ` Richard Guenther
  0 siblings, 1 reply; 2+ messages in thread
From: Martin Jambor @ 2010-12-09 11:29 UTC (permalink / raw)
  To: GCC Patches; +Cc: Richard Guenther

Hi,

doing type conversion of TREE_ADDRESSIBLE basically requires keeping
the old aggregate around which beats the purpose of IPA-SRA.  The fix
is therefore to disallow such conversions when aggregating accesses.

The patch below has been generated from trunk but the same patch
applies to the 4.5 branch too and fixes the problem there as well.  I
have bootstrapped and tested it on both the trunk and the branch on
x86_64-linux.  OK for trunk now and for the 4.5 branch once it is
unfrozen?

Thanks,

Martin



2010-12-08  Martin Jambor  <mjambor@suse.cz>

	PR middle-end/46734
	* tree-sra.c (splice_param_accesses): Check that there are not
	multiple ADDRESSABLE types.

	* testsuite/g++.dg/tree-ssa/pr46734.C: New test.

Index: mine/gcc/testsuite/g++.dg/tree-ssa/pr46734.C
===================================================================
--- /dev/null
+++ mine/gcc/testsuite/g++.dg/tree-ssa/pr46734.C
@@ -0,0 +1,34 @@
+/* { dg-do compile } */
+/* { dg-options "-O -fipa-sra" } */
+
+struct A
+{
+  int *p;
+  A() {p = (int *) -1;}
+  ~A() {if (p && p != (int *) -1) *p = 0;}
+};
+
+struct B
+{
+  A a;
+  char data[23];
+  B() : a() {data[0] = 0;}
+};
+
+extern A ga;
+extern int *gi;
+extern void *gz;
+extern B *gb;
+
+static int * __attribute__ ((noinline)) foo (B *b, void *z)
+{
+  __builtin_memcpy (gz, z, 28);
+  ga = b->a;
+  return b->a.p;
+}
+
+int *bar (B *b, void *z)
+{
+  gb = b;
+  return foo (b, z);
+}
Index: mine/gcc/tree-sra.c
===================================================================
--- mine.orig/gcc/tree-sra.c
+++ mine/gcc/tree-sra.c
@@ -3587,7 +3587,10 @@ splice_param_accesses (tree parm, bool *
 	  else if (ac2->size != access->size)
 	    return NULL;
 
-	  if (access_precludes_ipa_sra_p (ac2))
+	  if (access_precludes_ipa_sra_p (ac2)
+	      || (ac2->type != access->type
+		  && (TREE_ADDRESSABLE (ac2->type)
+		      || TREE_ADDRESSABLE (access->type))))
 	    return NULL;
 
 	  modification |= ac2->write;

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH, PR 46734, 4.5, 4.6] No TREE_ADDRESSIBLE types conversion in IPA-SRA
  2010-12-09 11:29 [PATCH, PR 46734, 4.5, 4.6] No TREE_ADDRESSIBLE types conversion in IPA-SRA Martin Jambor
@ 2010-12-09 12:49 ` Richard Guenther
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Guenther @ 2010-12-09 12:49 UTC (permalink / raw)
  To: Martin Jambor; +Cc: GCC Patches

On Thu, 9 Dec 2010, Martin Jambor wrote:

> Hi,
> 
> doing type conversion of TREE_ADDRESSIBLE basically requires keeping
> the old aggregate around which beats the purpose of IPA-SRA.  The fix
> is therefore to disallow such conversions when aggregating accesses.
> 
> The patch below has been generated from trunk but the same patch
> applies to the 4.5 branch too and fixes the problem there as well.  I
> have bootstrapped and tested it on both the trunk and the branch on
> x86_64-linux.  OK for trunk now and for the 4.5 branch once it is
> unfrozen?

Ok.

Thanks,
Richard.

> Thanks,
> 
> Martin
> 
> 
> 
> 2010-12-08  Martin Jambor  <mjambor@suse.cz>
> 
> 	PR middle-end/46734
> 	* tree-sra.c (splice_param_accesses): Check that there are not
> 	multiple ADDRESSABLE types.
> 
> 	* testsuite/g++.dg/tree-ssa/pr46734.C: New test.
> 
> Index: mine/gcc/testsuite/g++.dg/tree-ssa/pr46734.C
> ===================================================================
> --- /dev/null
> +++ mine/gcc/testsuite/g++.dg/tree-ssa/pr46734.C
> @@ -0,0 +1,34 @@
> +/* { dg-do compile } */
> +/* { dg-options "-O -fipa-sra" } */
> +
> +struct A
> +{
> +  int *p;
> +  A() {p = (int *) -1;}
> +  ~A() {if (p && p != (int *) -1) *p = 0;}
> +};
> +
> +struct B
> +{
> +  A a;
> +  char data[23];
> +  B() : a() {data[0] = 0;}
> +};
> +
> +extern A ga;
> +extern int *gi;
> +extern void *gz;
> +extern B *gb;
> +
> +static int * __attribute__ ((noinline)) foo (B *b, void *z)
> +{
> +  __builtin_memcpy (gz, z, 28);
> +  ga = b->a;
> +  return b->a.p;
> +}
> +
> +int *bar (B *b, void *z)
> +{
> +  gb = b;
> +  return foo (b, z);
> +}
> Index: mine/gcc/tree-sra.c
> ===================================================================
> --- mine.orig/gcc/tree-sra.c
> +++ mine/gcc/tree-sra.c
> @@ -3587,7 +3587,10 @@ splice_param_accesses (tree parm, bool *
>  	  else if (ac2->size != access->size)
>  	    return NULL;
>  
> -	  if (access_precludes_ipa_sra_p (ac2))
> +	  if (access_precludes_ipa_sra_p (ac2)
> +	      || (ac2->type != access->type
> +		  && (TREE_ADDRESSABLE (ac2->type)
> +		      || TREE_ADDRESSABLE (access->type))))
>  	    return NULL;
>  
>  	  modification |= ac2->write;
> 
> 

-- 
Richard Guenther <rguenther@suse.de>
Novell / SUSE Labs
SUSE LINUX Products GmbH - Nuernberg - AG Nuernberg - HRB 16746 - GF: Markus Rex

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-12-09 12:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-09 11:29 [PATCH, PR 46734, 4.5, 4.6] No TREE_ADDRESSIBLE types conversion in IPA-SRA Martin Jambor
2010-12-09 12:49 ` 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).