Patchwork [trans-mem] do not go through the run-time for clone calls

login
register
mail settings
Submitter Aldy Hernandez
Date Feb. 16, 2011, 4:59 p.m.
Message ID <4D5C026F.8020402@redhat.com>
Download mbox | patch
Permalink /patch/83377/
State New
Headers show

Comments

Aldy Hernandez - Feb. 16, 2011, 4:59 p.m.
And now for the actual optimization...

There is no need to go through the run-time when calling a clone.  We 
can just call the clone directly.

OK?
* trans-mem.c (ipa_tm_transform_calls_redirect): No need to go
	through the run-time when calling a clone.

Patch

Index: testsuite/gcc.dg/tm/20110216.c
===================================================================
--- testsuite/gcc.dg/tm/20110216.c	(revision 0)
+++ testsuite/gcc.dg/tm/20110216.c	(revision 0)
@@ -0,0 +1,15 @@ 
+/* { dg-do compile } */
+/* { dg-options "-fgnu-tm" } */
+
+int george;
+
+__attribute__((transaction_callable))
+void q1()
+{
+  __transaction [[atomic]] {
+      george=999;
+  }
+  q1();
+}
+
+/* { dg-final { scan-assembler-not "_ITM_getTMCloneOrIrrevocable" } } */
Index: trans-mem.c
===================================================================
--- trans-mem.c	(revision 170214)
+++ trans-mem.c	(working copy)
@@ -4294,8 +4294,14 @@  ipa_tm_transform_calls_redirect (struct 
   struct cgraph_edge *e = cgraph_edge (node, stmt);
   tree fndecl = gimple_call_fndecl (stmt);
 
+  /* No need to go through _ITM_getTMCloneOrIrrevocable.  We can just
+     call the clone directly if we know it.  */
+  if (DECL_IS_TM_CLONE (e->callee->decl))
+    fndecl = e->callee->decl;
+  else
+    fndecl = find_tm_replacement_function (fndecl);
+
   /* If there is a replacement, use it, otherwise use the clone.  */
-  fndecl = find_tm_replacement_function (fndecl);
   if (fndecl)
     {
       new_node = cgraph_node (fndecl);