This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix another case of noreturn call with TREE_ADDRESSABLE type on lhs (PR c++/71100)
- From: Jason Merrill <jason at redhat dot com>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: Richard Biener <rguenther at suse dot de>, gcc-patches List <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 18 May 2016 17:05:48 -0400
- Subject: Re: [PATCH] Fix another case of noreturn call with TREE_ADDRESSABLE type on lhs (PR c++/71100)
- Authentication-results: sourceware.org; auth=none
- References: <20160518205517 dot GT28550 at tucnak dot redhat dot com>
OK.
Jason
On Wed, May 18, 2016 at 4:55 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> In 6+ we require that lhs is present if the return type of a call is
> TREE_ADDRESSABLE, apparently this function has been missed.
>
> Fixed thusly, bootstrapped/regtested (at r236371, later trunk fails
> miserably on both x86_64-linux and i686-linux), ok for trunk/6.2?
>
> 2016-05-18 Jakub Jelinek <jakub@redhat.com>
>
> PR c++/71100
> * cgraph.c (cgraph_edge::redirect_call_stmt_to_callee): Don't drop
> lhs if it has TREE_ADDRESSABLE type.
>
> * g++.dg/opt/pr71100.C: New test.
>
> --- gcc/cgraph.c.jj 2016-05-16 18:53:43.000000000 +0200
> +++ gcc/cgraph.c 2016-05-18 10:53:39.491189469 +0200
> @@ -1515,7 +1515,8 @@ cgraph_edge::redirect_call_stmt_to_calle
> /* If the call becomes noreturn, remove the LHS if possible. */
> if (lhs
> && (gimple_call_flags (new_stmt) & ECF_NORETURN)
> - && TREE_CODE (TYPE_SIZE_UNIT (TREE_TYPE (lhs))) == INTEGER_CST)
> + && TREE_CODE (TYPE_SIZE_UNIT (TREE_TYPE (lhs))) == INTEGER_CST
> + && !TREE_ADDRESSABLE (TREE_TYPE (lhs)))
> {
> if (TREE_CODE (lhs) == SSA_NAME)
> {
> --- gcc/testsuite/g++.dg/opt/pr71100.C.jj 2016-05-18 10:56:12.798070065 +0200
> +++ gcc/testsuite/g++.dg/opt/pr71100.C 2016-05-18 10:56:07.974136754 +0200
> @@ -0,0 +1,18 @@
> +// PR c++/71100
> +// { dg-do compile }
> +// { dg-options "-O2" }
> +
> +struct D { ~D (); };
> +struct E { D foo () { throw 1; } };
> +
> +inline void
> +bar (D (E::*f) (), E *o)
> +{
> + (o->*f) ();
> +}
> +
> +void
> +baz (E *o)
> +{
> + bar (&E::foo, o);
> +}
>
> Jakub