From patchwork Wed Feb 16 16:59:27 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [trans-mem] do not go through the run-time for clone calls Date: Wed, 16 Feb 2011 06:59:27 -0000 From: Aldy Hernandez X-Patchwork-Id: 83377 Message-Id: <4D5C026F.8020402@redhat.com> To: gcc-patches , Richard Henderson 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. 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);