From patchwork Mon Feb 25 23:10:03 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 223067 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 1BF782C0296 for ; Tue, 26 Feb 2013 10:10:34 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1362438635; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject: References:In-Reply-To:Content-Type:Mailing-List:Precedence: List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=3HblYEHrrUMoF4bdXplc2elWEmU=; b=MW5elMV/6IOdPkQ Hs5v8fbF/qM1gW2ZKl5eN889zyZJPVtfXQR0GZdugLTEM5AkIAbCIPJwDwJ7NrZb 2V14Vjjco7QPcpDe0WK5nbabp9/Q3rAwvPCPCtBRSlwwMUQU5z2EtWgP5ruUquVq vmRbGZi4oQGLSmCjgv8T+4gpiETw= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject:References:In-Reply-To:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=f29UPkwohE00f5xP21jH3uJQFk66kPiJFlTU6gcqnTRjCYe5hJDCjnPcRddkxg Us528jCxm1QOPZDyKmZEuy5UKgPMv7QZX476WIpg+p3KxFrj/nNSNExhLUuI/RcV qQbox9eIy1od8BxjvQ3g5Yvd+vtQ7VgoCHULoAkNSlsi8=; Received: (qmail 26529 invoked by alias); 25 Feb 2013 23:10:27 -0000 Received: (qmail 26517 invoked by uid 22791); 25 Feb 2013 23:10:26 -0000 X-SWARE-Spam-Status: No, hits=-7.4 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, KHOP_SPAMHAUS_DROP, KHOP_THREADED, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, RP_MATCHES_RCVD, SPF_HELO_PASS, TW_TM 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; Mon, 25 Feb 2013 23:10:18 +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.14.4/8.14.4) with ESMTP id r1PNAGvc003263 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 25 Feb 2013 18:10:18 -0500 Received: from houston.quesejoda.com (vpn-49-31.rdu2.redhat.com [10.10.49.31]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r1PNA3Vh006245; Mon, 25 Feb 2013 18:10:06 -0500 Message-ID: <512BEF4B.1090001@redhat.com> Date: Mon, 25 Feb 2013 17:10:03 -0600 From: Aldy Hernandez User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: Jason Merrill CC: gcc-patches , Richard Henderson Subject: Re: [PR 56419/c++]: C++ front end silently drops transactions References: <5127867A.1000507@redhat.com> <512BBEE0.9000801@redhat.com> In-Reply-To: <512BBEE0.9000801@redhat.com> 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 >> Anyways, I've fixed the problem by setting TREE_SIDE_EFFECTS if the >> transaction body has side effects. Perhaps we should do this for >> build_transaction_expr() as well? > > I would think managing the transaction boundaries would always have > side-effects, no? If that's correct, I'd set the flag unconditionally > in begin_transaction_stmt and build_transaction_expr. Yeah, any transaction would have to go through the run-time at least once, so that is definitely a side-effect. OK? + PR c++/56419 + * semantics.c (begin_transaction_stmt): Set TREE_SIDE_EFFECTS. + (build_transaction_expr): Same. diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 458ed26..589c821 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -5108,6 +5108,7 @@ begin_transaction_stmt (location_t loc, tree *pcompound, int flags) "transactional memory support enabled"))); TRANSACTION_EXPR_BODY (r) = push_stmt_list (); + TREE_SIDE_EFFECTS (r) = 1; return r; } @@ -5157,6 +5158,7 @@ build_transaction_expr (location_t loc, tree expr, int flags, tree noex) ret = build1 (TRANSACTION_EXPR, TREE_TYPE (expr), expr); if (flags & TM_STMT_ATTR_RELAXED) TRANSACTION_EXPR_RELAXED (ret) = 1; + TREE_SIDE_EFFECTS (ret) = 1; SET_EXPR_LOCATION (ret, loc); return ret; } diff --git a/gcc/testsuite/g++.dg/tm/pr56419.C b/gcc/testsuite/g++.dg/tm/pr56419.C new file mode 100644 index 0000000..c9a33a8 --- /dev/null +++ b/gcc/testsuite/g++.dg/tm/pr56419.C @@ -0,0 +1,13 @@ +// { dg-do compile } +// { dg-options "-fgnu-tm" } + +int x = 0; +int inc_func(int i) { + for (int j = 0; j < i; ++j) + { + __transaction_atomic { x+=1; } + } + return 0; +} + +// { dg-final { scan-assembler "ITM_commitTransaction" } }