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]

[trans-mem] do not inline wrapper functions


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?

	* 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)


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