This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix invalid tree sharing caused by the inliner (PR tree-optimization/59386)


On Wed, 11 Dec 2013, Jakub Jelinek wrote:

> Hi!
> 
> If id->retvar isn't a decl (can happen for DECL_BY_REFERENCE returns),
> then we can end up with invalid tree sharing because we reuse it more than
> once (on the following testcase id->retvar is a COMPONENT_REF).
> 
> Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
> trunk?

Ok.

Thanks,
Richard.

> 2013-12-11  Jakub Jelinek  <jakub@redhat.com>
> 
> 	PR tree-optimization/59386
> 	* tree-inline.c (remap_gimple_stmt): If not id->do_not_unshare,
> 	unshare_expr (id->retval) before passing it to gimple_build_assign.
> 
> 	* gcc.c-torture/compile/pr59386.c: New test.
> 
> --- gcc/tree-inline.c.jj	2013-12-10 08:52:13.000000000 +0100
> +++ gcc/tree-inline.c	2013-12-10 17:04:09.022069945 +0100
> @@ -1273,7 +1273,9 @@ remap_gimple_stmt (gimple stmt, copy_bod
>  		  || ! SSA_NAME_VAR (retval)
>  		  || TREE_CODE (SSA_NAME_VAR (retval)) != RESULT_DECL)))
>          {
> -	  copy = gimple_build_assign (id->retvar, retval);
> +	  copy = gimple_build_assign (id->do_not_unshare
> +				      ? id->retvar : unshare_expr (id->retvar),
> +				      retval);
>  	  /* id->retvar is already substituted.  Skip it on later remapping.  */
>  	  skip_first = true;
>  	}
> --- gcc/testsuite/gcc.c-torture/compile/pr59386.c.jj	2013-12-10 17:06:39.389291052 +0100
> +++ gcc/testsuite/gcc.c-torture/compile/pr59386.c	2013-12-10 17:05:37.000000000 +0100
> @@ -0,0 +1,24 @@
> +/* PR tree-optimization/59386 */
> +
> +struct S { int s; };
> +struct T { int t; struct S u; } c;
> +int b;
> +
> +struct S
> +foo ()
> +{
> +  struct T d;
> +  if (b)
> +    while (c.t)
> +      ;
> +  else
> +    return d.u;
> +}
> +
> +struct S
> +bar ()
> +{
> +  struct T a;
> +  a.u = foo ();
> +  return a.u;
> +}
> 
> 	Jakub
> 
> 

-- 
Richard Biener <rguenther@suse.de>
SUSE / SUSE Labs
SUSE LINUX Products GmbH - Nuernberg - AG Nuernberg - HRB 16746
GF: Jeff Hawn, Jennifer Guild, Felix Imend"orffer


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]