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] Make result_slot TREE_ADDRESSABLE if DECL_RESULT in inlined fn is (PR gcov-profile/34609)


On Jan 4, 2008 8:50 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> This testcase fails with the early inlining (but not with normal inlining,
> where there are enough optimizations in the middle to clean the unused code
> up).  The problem seems to be that when declare_return_variable is called
> with bar's RESULT_DECL as result_slot (non-addressable) and foo's
> RESULT_DECL as DECL_RESULT (addressable), nothing makes the result_slot
> addressable and so tree checking fails, because address was taken from
> a non-addressable object.
>
> Fixed thusly, bootstrapped/regtested on x86_64-linux.  Ok for trunk?

Ok.

Thanks,
Richard.

> 2008-01-03  Jakub Jelinek  <jakub@redhat.com>
>
>         PR gcov-profile/34609
>         * tree-inline.c (declare_return_variable): Set TREE_ADDRESSABLE on
>         return_slot if result is TREE_ADDRESSABLE.
>
>         * g++.dg/gcov/gcov-6.C: New test.
>
> --- gcc/tree-inline.c.jj        2008-01-03 17:55:22.000000000 +0100
> +++ gcc/tree-inline.c   2008-01-03 17:59:52.000000000 +0100
> @@ -1,5 +1,5 @@
>  /* Tree inlining.
> -   Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007
> +   Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
>     Free Software Foundation, Inc.
>     Contributed by Alexandre Oliva <aoliva@redhat.com>
>
> @@ -1691,6 +1691,7 @@ declare_return_variable (copy_body_data
>         {
>           var = return_slot;
>           gcc_assert (TREE_CODE (var) != SSA_NAME);
> +         TREE_ADDRESSABLE (var) |= TREE_ADDRESSABLE (result);
>         }
>        if ((TREE_CODE (TREE_TYPE (result)) == COMPLEX_TYPE
>             || TREE_CODE (TREE_TYPE (result)) == VECTOR_TYPE)
> --- gcc/testsuite/g++.dg/gcov/gcov-6.C.jj       2008-01-03 18:35:47.000000000 +0100
> +++ gcc/testsuite/g++.dg/gcov/gcov-6.C  2008-01-03 18:31:44.000000000 +0100
> @@ -0,0 +1,29 @@
> +// PR gcov-profile/34609
> +// { dg-do compile }
> +// { dg-options "-O -ftest-coverage" }
> +
> +struct A
> +{
> +  int i;
> +  int &get () { return i; }
> +};
> +
> +inline A foo ()
> +{
> +  A a;
> +  a.get ();
> +  return a;
> +}
> +
> +inline A bar ()
> +{
> +  return foo ();
> +}
> +
> +void baz ()
> +{
> +  A a;
> +  a = bar ();
> +}
> +
> +// { dg-final { cleanup-coverage-files } }
>
>         Jakub
>


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