From patchwork Wed Feb 2 17:14:54 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 81494 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 9FF75B7101 for ; Thu, 3 Feb 2011 04:15:08 +1100 (EST) Received: (qmail 14939 invoked by alias); 2 Feb 2011 17:15:03 -0000 Received: (qmail 14913 invoked by uid 22791); 2 Feb 2011 17:15:02 -0000 X-SWARE-Spam-Status: No, hits=-6.3 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, TW_TN, TW_VN, 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, 02 Feb 2011 17:14:57 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id p12HEtM4027366 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 2 Feb 2011 12:14:55 -0500 Received: from vishnu.quesejoda.com (vpn-239-147.phx2.redhat.com [10.3.239.147]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p12HEsee014652; Wed, 2 Feb 2011 12:14:54 -0500 Message-ID: <4D49910E.8060206@redhat.com> Date: Wed, 02 Feb 2011 11:14:54 -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: Patrick Marlier CC: Richard Henderson , "gcc-patches@gcc.gnu.org" Subject: Re: [trans-mem] PR46941: Mark new/delete operators as transaction_pure References: <4D2DF519.1020302@redhat.com> <4D2DFA0E.7030805@redhat.com> <4D35A768.5040108@unine.ch> In-Reply-To: <4D35A768.5040108@unine.ch> 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 On 01/18/11 08:44, Patrick Marlier wrote: > I am not agree. Functions should be marked as transaction_safe not > transaction_pure because libitm is managing those new/delete safe > allocations. Patrick is right. I was wrong. Attached are his suggestions, plus modifications to make it work with 32-bits. Richard, the [new] operator which you implement in the run-time is mangled for 64-bits. I added a 32-bit version when !__LP64__. I don't know how thorough you'd like to check for 64/32 bits. I'm avoiding having to come up with fancy autoconf checks. OK for branch? libitm/ * alloc_cpp.cc: Handle non-64 bit variants for new(). gcc/ * cp/decl.c (push_cp_library_fn): Set attribute to transaction_safe. * testsuite/g++.dg/tm/pr46941.C: Test that new/delete calls are transformed into calls into the runtime. Index: libitm/libitm.map =================================================================== --- libitm/libitm.map (revision 169292) +++ libitm/libitm.map (working copy) @@ -170,7 +170,9 @@ LIBITM_1.0 { _ITM_dropReferences; _ZGTtnwm; + _ZGTtnwj; _ZGTtnam; + _ZGTtnaj; _ZGTtdlPv; _ZGTtdaPv; _ZGTtnwmRKSt9nothrow_t; Index: libitm/alloc_cpp.cc =================================================================== --- libitm/alloc_cpp.cc (revision 169292) +++ libitm/alloc_cpp.cc (working copy) @@ -62,7 +62,11 @@ del_opvnt (void *ptr) /* Wrap: operator new (std::size_t sz) */ void * +#ifdef __LP64__ _ZGTtnwm (size_t sz) +#else +_ZGTtnwj (size_t sz) +#endif { void *r = _Znwm (sz); if (r) @@ -82,7 +86,11 @@ _ZGTtnwmRKSt9nothrow_t (size_t sz, c_not /* Wrap: operator new[] (std::size_t sz) */ void * +#ifdef __LP64__ _ZGTtnam (size_t sz) +#else +_ZGTtnaj (size_t sz) +#endif { void *r = _Znam (sz); if (r) Index: gcc/testsuite/g++.dg/tm/pr46941.C =================================================================== --- gcc/testsuite/g++.dg/tm/pr46941.C (revision 169292) +++ gcc/testsuite/g++.dg/tm/pr46941.C (working copy) @@ -29,3 +29,9 @@ void deallocatearray(Obj *o[]) { delete [] o; } + +/* The delete/new operators are handled by the libitm runtime. */ +/* { dg-final { scan-assembler "_ZGTtnw\[mj\]" } } */ +/* { dg-final { scan-assembler "_ZGTtna\[mj\]" } } */ +/* { dg-final { scan-assembler "_ZGTtdlPv" } } */ +/* { dg-final { scan-assembler "_ZGTtdaPv" } } */ Index: gcc/cp/decl.c =================================================================== --- gcc/cp/decl.c (revision 169374) +++ gcc/cp/decl.c (working copy) @@ -3776,7 +3776,7 @@ push_cp_library_fn (enum tree_code opera type); pushdecl (fn); if (flag_tm) - apply_tm_attr (fn, get_identifier ("transaction_pure")); + apply_tm_attr (fn, get_identifier ("transaction_safe")); return fn; }