This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [trans-mem] do not inline wrapper functions
- From: Richard Guenther <richard dot guenther at gmail dot com>
- To: Aldy Hernandez <aldyh at redhat dot com>
- Cc: rth at redhat dot com, gcc-patches at gcc dot gnu dot org
- Date: Thu, 10 Sep 2009 13:48:14 +0200
- Subject: Re: [trans-mem] do not inline wrapper functions
- References: <20090910114346.GA25670@redhat.com>
On Thu, Sep 10, 2009 at 1:43 PM, Aldy Hernandez<aldyh@redhat.com> wrote:
> Imagine candy(), a wrapper for tootsie_roll(). ?Currently, if the
> inliner thinks candy() can be inlined, it will do so, thus never
> performing the tootsie_roll() replacement. ?This is because the inliner
> runs before the TM does its thing. ?(See test below).
>
> I have fixed the problem by making the inliner ignore inline candidates which
> will get wrapped.
>
> OK for branch?
Shouldn't the frontend instead simply mark the call as
CALL_CANNOT_INLINE_P? Or somehow make it obvious that
the call statement call fndecl isn't the real function that gets called?
I can think of other analysis passes that would get confused here.
Richard.
> ? ? ? ?* tree.h (find_tm_replacement_function): Protoize.
> ? ? ? ?* trans-mem.c (find_tm_replacement_function): Declare extern.
> ? ? ? ?* ipa-inline.c (cgraph_decide_inlining_incrementally): Do not
> ? ? ? ?inline TM wrapper functions.
>
> Index: tree.h
> ===================================================================
> --- tree.h ? ? ?(revision 151563)
> +++ tree.h ? ? ?(working copy)
> @@ -5276,6 +5276,7 @@ extern bool is_tm_pure (tree);
> ?extern bool is_tm_callable (tree);
> ?extern bool is_tm_irrevocable (tree);
> ?extern void record_tm_replacement (tree, tree);
> +extern tree find_tm_replacement_function (tree);
>
> ?/* In tree-inline.c. ?*/
>
> Index: testsuite/gcc.dg/tm/wrap-4.c
> ===================================================================
> --- testsuite/gcc.dg/tm/wrap-4.c ? ? ? ?(revision 0)
> +++ testsuite/gcc.dg/tm/wrap-4.c ? ? ? ?(revision 0)
> @@ -0,0 +1,15 @@
> +/* { dg-do compile } */
> +/* { dg-options "-fgnu-tm -fdump-tree-optimized -O2" } */
> +
> +static void candy() { candycane(); }
> +
> +static void tootsie_roll () __attribute__((tm_wrap (candy)));
> +static void tootsie_roll () { bark(); }
> +
> +void foo()
> +{
> + ?__tm_atomic ?candy();
> +}
> +
> +/* { dg-final { scan-tree-dump-times "candy" 0 "optimized" } } */
> +/* { dg-final { cleanup-tree-dump "optimized" } } */
> Index: ipa-inline.c
> ===================================================================
> --- ipa-inline.c ? ? ? ?(revision 151563)
> +++ ipa-inline.c ? ? ? ?(working copy)
> @@ -1500,6 +1500,15 @@ cgraph_decide_inlining_incrementally (st
> ? ? ? ? ? ? ?}
> ? ? ? ? ? ?continue;
> ? ? ? ? ?}
> + ? ? ? if (find_tm_replacement_function (e->callee->decl) != NULL_TREE)
> + ? ? ? ? {
> + ? ? ? ? ? if (dump_file)
> + ? ? ? ? ? ? {
> + ? ? ? ? ? ? ? indent_to (dump_file, depth);
> + ? ? ? ? ? ? ? fprintf (dump_file, "Not inlining: TM replacement found.\n");
> + ? ? ? ? ? ? }
> + ? ? ? ? ? continue;
> + ? ? ? ? }
>
> ? ? ? ?if (cgraph_maybe_hot_edge_p (e) && leaf_node_p (e->callee)
> ? ? ? ? ? ?&& optimize_function_for_speed_p (cfun))
> Index: trans-mem.c
> ===================================================================
> --- trans-mem.c (revision 151577)
> +++ trans-mem.c (working copy)
> @@ -340,7 +340,7 @@ record_tm_replacement (tree from, tree t
>
> ?/* Return a TM-aware replacement function for DECL. ?*/
>
> -static tree
> +tree
> ?find_tm_replacement_function (tree fndecl)
> ?{
> ? if (tm_wrap_map)
>