From patchwork Thu Oct 11 20:56:53 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 190999 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 D5D4F2C00F4 for ; Fri, 12 Oct 2012 07:57:05 +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=1350593827; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=1GY0KWb SJfnl6YNPlcURC9LVx3w=; b=sPmaXAVU1GRtEvcge7qC2X/YvbQHH49TmpPXLQW 6r0e3w0p6c6OD1To7XhfjdOHmJcnsvcpz1Sou+Zk+eK4UnFGt0r7fFRN25U+FGaz qzi/0Q62tumcpjCXLuh+IVlnzOw6bdcBNgrVX3JvP+eTJXKwWudBuGVtkh6Ba5AG 4tUM= 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:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=FHuSbe4NwaQxDBq4UBTs47Y7ph0ApQFk61wNe9arxCLBwV60S6nhOTCyQ0RxaB z1X+HU70W+EK8IooJuLvwEZsicStbpFbSI9EZGYA1nB52+1X55JEZ+pt9XbPPYLz PP95AB1FL16F8fs/BPJcG9wVgoKVhdTKolLi3Fi48tDDs=; Received: (qmail 30305 invoked by alias); 11 Oct 2012 20:57:01 -0000 Received: (qmail 30296 invoked by uid 22791); 11 Oct 2012 20:57:01 -0000 X-SWARE-Spam-Status: No, hits=-7.3 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, KHOP_SPAMHAUS_DROP, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, RP_MATCHES_RCVD, SPF_HELO_PASS 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; Thu, 11 Oct 2012 20:56:55 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q9BKuten025328 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 11 Oct 2012 16:56:55 -0400 Received: from reynosa.quesejoda.com (vpn-10-52.rdu.redhat.com [10.11.10.52]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q9BKurfB021567; Thu, 11 Oct 2012 16:56:54 -0400 Message-ID: <50773295.7000005@redhat.com> Date: Thu, 11 Oct 2012 16:56:53 -0400 From: Aldy Hernandez User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120911 Thunderbird/15.0.1 MIME-Version: 1.0 To: gcc-patches , Richard Henderson CC: Torvald Riegel Subject: PR/54893: allow volatiles inside relaxed transactions 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 Apparently we were a bit too aggressive on disallowing volatiles inside transactions. Torvald seems to agree that volatiles should be allowed inside relaxed transactions, since they will go into serial irrevocable mode anyhow. The following patch fixes the PR. I did not include a test that fails on a volatile in an atomic transaction because there is already one in the testsuite. OK pending tests? PR middle-end/54893 * trans-mem.c (diagnose_tm_1_op): Allow volatiles inside relaxed transactions. diff --git a/gcc/testsuite/c-c++-common/tm/pr54893.c b/gcc/testsuite/c-c++-common/tm/pr54893.c new file mode 100644 index 0000000..df26f25 --- /dev/null +++ b/gcc/testsuite/c-c++-common/tm/pr54893.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-fgnu-tm" } */ + +/* Test that volatiles are allowed inside relaxed transactions. */ + +volatile int test_var = 0; + +int main() +{ + __transaction_relaxed { + test_var++; + } +} diff --git a/gcc/trans-mem.c b/gcc/trans-mem.c index ef384ac..dc08bc6 100644 --- a/gcc/trans-mem.c +++ b/gcc/trans-mem.c @@ -561,7 +561,7 @@ diagnose_tm_1_op (tree *tp, int *walk_subtrees ATTRIBUTE_UNUSED, if ((code == VAR_DECL || code == RESULT_DECL || code == PARM_DECL) - && d->block_flags & (DIAG_TM_SAFE | DIAG_TM_RELAXED) + && d->block_flags & DIAG_TM_SAFE && TREE_THIS_VOLATILE (TREE_TYPE (*tp)) && !d->saw_volatile) {