From patchwork Wed Jan 12 18:38:17 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 78607 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 970BCB6F2B for ; Thu, 13 Jan 2011 05:38:34 +1100 (EST) Received: (qmail 7438 invoked by alias); 12 Jan 2011 18:38:29 -0000 Received: (qmail 7327 invoked by uid 22791); 12 Jan 2011 18:38:28 -0000 X-SWARE-Spam-Status: No, hits=-6.3 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, 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, 12 Jan 2011 18:38:19 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id p0CIcIgi020487 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 12 Jan 2011 13:38:18 -0500 Received: from vishnu.quesejoda.com (vpn-233-126.phx2.redhat.com [10.3.233.126]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p0CIcHx6016854; Wed, 12 Jan 2011 13:38:18 -0500 Message-ID: <4D2DF519.1020302@redhat.com> Date: Wed, 12 Jan 2011 12:38:17 -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: Richard Henderson , gcc-patches@gcc.gnu.org Subject: [trans-mem] PR46941: Mark new/delete operators as transaction_pure 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 Same spice, different name. I've used push_cp_library_fn() to mark the function, as opposed to the caller, since only the new/delete operators use this function. OK for branch? * cp/decl.c (push_cp_library_fn): Mark function as transaction_pure. Index: testsuite/g++.dg/tm/pr46941.C =================================================================== --- testsuite/g++.dg/tm/pr46941.C (revision 0) +++ testsuite/g++.dg/tm/pr46941.C (revision 0) @@ -0,0 +1,31 @@ +// { dg-do "compile" } +// { dg-options "-fgnu-tm" } + +class Obj +{ + int dummy; +}; + +__attribute__((transaction_safe)) +Obj* allocate() +{ + return new Obj; +} + +__attribute__((transaction_safe)) +void deallocate(Obj * o) +{ + delete o; +} + +__attribute__((transaction_safe)) +Obj* allocatearray() +{ + return new Obj[2]; +} + +__attribute__((transaction_safe)) +void deallocatearray(Obj *o[]) +{ + delete [] o; +} Index: cp/decl.c =================================================================== --- cp/decl.c (revision 168675) +++ cp/decl.c (working copy) @@ -3775,6 +3775,8 @@ push_cp_library_fn (enum tree_code opera operator_code, type); pushdecl (fn); + if (flag_tm) + apply_tm_attr (fn, get_identifier ("transaction_pure")); return fn; }