This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix invalid tree sharing caused by the inliner (PR tree-optimization/59386)
- From: Richard Biener <rguenther at suse dot de>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Wed, 11 Dec 2013 10:01:05 +0100 (CET)
- Subject: Re: [PATCH] Fix invalid tree sharing caused by the inliner (PR tree-optimization/59386)
- Authentication-results: sourceware.org; auth=none
- References: <20131211082805 dot GA892 at tucnak dot redhat dot com>
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