From patchwork Wed Feb 16 16:59:27 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 83377 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id BA224B70CD for ; Thu, 17 Feb 2011 03:59:38 +1100 (EST) Received: (qmail 12267 invoked by alias); 16 Feb 2011 16:59:35 -0000 Received: (qmail 12258 invoked by uid 22791); 16 Feb 2011 16:59:34 -0000 X-SWARE-Spam-Status: No, hits=-6.4 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, TW_FN, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 16 Feb 2011 16:59:30 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p1GGxSCL000883 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 16 Feb 2011 11:59:28 -0500 Received: from vishnu.quesejoda.com (vpn-224-74.phx2.redhat.com [10.3.224.74]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p1GGxSAL014374; Wed, 16 Feb 2011 11:59:28 -0500 Message-ID: <4D5C026F.8020402@redhat.com> Date: Wed, 16 Feb 2011 10:59:27 -0600 From: Aldy Hernandez User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101209 Fedora/3.1.7-0.35.b3pre.fc14 Lightning/1.0b3pre Thunderbird/3.1.7 MIME-Version: 1.0 To: gcc-patches , Richard Henderson Subject: [trans-mem] do not go through the run-time for clone calls Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org 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);