This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH, PR ipa/71633] Fix inlining into thunks
- From: Richard Biener <richard dot guenther at gmail dot com>
- To: Ilya Enkovich <enkovich dot gnu at gmail dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 12 Jul 2016 12:09:22 +0200
- Subject: Re: [PATCH, PR ipa/71633] Fix inlining into thunks
- Authentication-results: sourceware.org; auth=none
- References: <20160711102219.GA51593@msticlxl57.ims.intel.com>
On Mon, Jul 11, 2016 at 12:22 PM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
> Hi,
>
> Currently when we expand thunk in inliner we assume its body
> has a single call. This is wrong for cases when thunk is
> instrumented. It means we might try to continue inlining
> for wrong edge. This simple patch fixes it.
>
> Bootstrapped and regtested on x86_64-unknown-linux-gnu.
> OK for trunk?
Ok.
Thanks,
Richard.
> Thanks,
> Ilya
> --
> gcc/
>
> 2016-07-11 Ilya Enkovich <ilya.enkovich@intel.com>
>
> PR ipa/71633
> * ipa-inline-transform.c (inline_call): Support
> instrumented thunks.
>
> gcc/testsuite/
>
> 2016-07-11 Ilya Enkovich <ilya.enkovich@intel.com>
>
> PR ipa/71633
> * g++.dg/pr71633.C: New test.
>
>
> diff --git a/gcc/ipa-inline-transform.c b/gcc/ipa-inline-transform.c
> index 9ac1efc..a4ae305 100644
> --- a/gcc/ipa-inline-transform.c
> +++ b/gcc/ipa-inline-transform.c
> @@ -319,10 +319,14 @@ inline_call (struct cgraph_edge *e, bool update_original,
> to = to->global.inlined_to;
> if (to->thunk.thunk_p)
> {
> + struct cgraph_node *target = to->callees->callee;
> if (in_lto_p)
> to->get_untransformed_body ();
> to->expand_thunk (false, true);
> - e = to->callees;
> + /* When thunk is instrumented we may have multiple callees. */
> + for (e = to->callees; e && e->callee != target; e = e->next_callee)
> + ;
> + gcc_assert (e);
> }
>
>
> diff --git a/gcc/testsuite/g++.dg/pr71633.C b/gcc/testsuite/g++.dg/pr71633.C
> new file mode 100644
> index 0000000..bb69bbb
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/pr71633.C
> @@ -0,0 +1,28 @@
> +/* PR71633 */
> +// { dg-do compile { target i?86-*-* x86_64-*-* } }
> +/* { dg-options "-fcheck-pointer-bounds -mmpx -O2" } */
> +
> +class c1
> +{
> + virtual void fn1 ();
> +};
> +
> +class c2
> +{
> + virtual int *fn2 () const;
> +};
> +
> +class c3 : c1, c2
> +{
> + int *fn2 () const;
> + int *fn3 (int) const;
> +};
> +
> +int *c3::fn2 () const
> +{
> +}
> +
> +int *c3::fn3 (int p) const
> +{
> + return fn3 (p);
> +}