From patchwork Mon Jan 10 18:45:29 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 78192 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 3CA8EB70E2 for ; Tue, 11 Jan 2011 05:45:38 +1100 (EST) Received: (qmail 16042 invoked by alias); 10 Jan 2011 18:45:37 -0000 Received: (qmail 16032 invoked by uid 22791); 10 Jan 2011 18:45:36 -0000 X-SWARE-Spam-Status: No, hits=-6.3 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, TW_FN, TW_TM, 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; Mon, 10 Jan 2011 18:45:31 +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.13.8/8.13.8) with ESMTP id p0AIjTtS012729 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 10 Jan 2011 13:45:30 -0500 Received: from vishnu.quesejoda.com (vpn-234-15.phx2.redhat.com [10.3.234.15]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p0AIjTAS006213; Mon, 10 Jan 2011 13:45:29 -0500 Message-ID: <4D2B53C9.5080201@redhat.com> Date: Mon, 10 Jan 2011 12:45:29 -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@gcc.gnu.org, Richard Henderson Subject: [trans-mem] error on inlined asms 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 In the following test, we correctly error at -O0 because inline_death() has an unsafe construct and is being called from an atomic transaction. This error is triggered at ipa_tm_diagnose_transaction() because the diagnostic machinery (diagnose_tm*) has marked inline_death() as possibly entering irrevocable mode. However, at any optimization level, we don't error because we no longer have an irrevocable function call, instead the ASM has been inlined into the transaction. Since the asm complaining code gets run before inlining (diagnose_tm*), we don't notice the asm that ends up inside the transaction. static inline void inline_death () { __asm__ (""); } void tranfunction () { __transaction { inline_death (); } } My fix is to notice ASMs that have been inlined into transactions at IPA time, since we're iterating over the transaction code anyhow. OK for branch? * trans-mem.c (ipa_tm_diagnose_transaction): Do not allow asms in atomic transactions. Index: testsuite/c-c++-common/tm/inline-asm.c =================================================================== --- testsuite/c-c++-common/tm/inline-asm.c (revision 0) +++ testsuite/c-c++-common/tm/inline-asm.c (revision 0) @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-fgnu-tm -O1" } */ + +static inline void +inline_death () +{ + __asm__ (""); /* { dg-error "asm not allowed" } */ +} + +void +tranfunction () +{ + __transaction + { + inline_death (); + } +} Index: trans-mem.c =================================================================== --- trans-mem.c (revision 168123) +++ trans-mem.c (working copy) @@ -3929,6 +3929,13 @@ ipa_tm_diagnose_transaction (struct cgra gimple stmt = gsi_stmt (gsi); tree fndecl; + if (gimple_code (stmt) == GIMPLE_ASM) + { + error_at (gimple_location (stmt), + "asm not allowed in atomic transaction"); + continue; + } + if (!is_gimple_call (stmt)) continue; fndecl = gimple_call_fndecl (stmt);