From patchwork Tue Feb 14 18:04:10 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 141158 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 B90BDB6FDA for ; Wed, 15 Feb 2012 05:04:35 +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=1329847476; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Message-ID:Date:From:User-Agent:MIME-Version:To:Subject: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=tZzPb8e Vy+xTBGaBARR7/SUA2vs=; b=ju57ruFMZcREZQYM7016+K/XHAnvJkx2y60FhEx XPdJGQVg34joat2ftUGmu5yaj2Z2EHz0AiyXWSWXhmrUpRaIiQOdWQ068TpMQpv2 B0wto67g0JBKn4RA6XsGwymR/OjvC/vGkN5UOV4xmIJXBX2Z+y89luAHeozj9Ngr eX0A= 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:Subject:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=Fmz5UHOiMNmUqbJE1JpiIwgkPvA0nOspo4k7reipQpuybs4Ep4XJ4Y8XkCVK/P fC9jTx0DWsSUXOHhbm0WNw2GqSCik7qij53pe8YroTtvvdPL5irjvTVLBz39MAcO jmo17IYwNoWbFEFTpm5A+jOR8keugM1CR73QBZTs7N0Yo=; Received: (qmail 3551 invoked by alias); 14 Feb 2012 18:04:29 -0000 Received: (qmail 3530 invoked by uid 22791); 14 Feb 2012 18:04:28 -0000 X-SWARE-Spam-Status: No, hits=-6.7 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; Tue, 14 Feb 2012 18:04:12 +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.14.4/8.14.4) with ESMTP id q1EI4BHl015647 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 14 Feb 2012 13:04:11 -0500 Received: from houston.quesejoda.com (vpn-234-249.phx2.redhat.com [10.3.234.249]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q1EI4BSN017620; Tue, 14 Feb 2012 13:04:11 -0500 Message-ID: <4F3AA21A.7050501@redhat.com> Date: Tue, 14 Feb 2012 12:04:10 -0600 From: Aldy Hernandez User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0) Gecko/20120131 Thunderbird/10.0 MIME-Version: 1.0 To: Richard Henderson , gcc-patches Subject: PR middle-end/52142: disallow inlining of certain TM_pure functions 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 Here we inline a transaction_pure function into a non transaction_pure function, but end up instrumenting all the memory operations in the tm_pure function regardless. As discussed in the PR, we should've disallowed inlining of TM_pure functions into non TM_pure functions. We are currently only disabling a subset of this, tm_safe callers. The patch below disallows all inlining of TM_pure functions into non TM_pure functions. No regressions. OK? (I'm not sure whether the "looks good" was because I'm handsome, or because it was an actual approval). PR middle-end/52142 * ipa-inline.c (can_inline_edge_p): Do not inline tm_pure functions into non-tm_pure functions. Index: testsuite/gcc.dg/tm/pr52142.c =================================================================== --- testsuite/gcc.dg/tm/pr52142.c (revision 0) +++ testsuite/gcc.dg/tm/pr52142.c (revision 0) @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-fgnu-tm -O1" } */ +static int global = 0; + +__attribute__((transaction_pure)) +static inline void purefunc() +{ + global++; +} + +__attribute__((transaction_safe)) +void f(); + +void push() +{ + __transaction_atomic { + f(); + purefunc(); + } +} + +/* { dg-final { scan-assembler-not "_ITM_RfWU4" } } */ Index: ipa-inline.c =================================================================== --- ipa-inline.c (revision 184181) +++ ipa-inline.c (working copy) @@ -284,10 +284,10 @@ can_inline_edge_p (struct cgraph_edge *e e->inline_failed = CIF_EH_PERSONALITY; inlinable = false; } - /* TM pure functions should not get inlined if the outer function is - a TM safe function. */ + /* TM pure functions should not be inlined into non-TM_pure + functions. */ else if (is_tm_pure (callee->decl) - && is_tm_safe (e->caller->decl)) + && !is_tm_pure (e->caller->decl)) { e->inline_failed = CIF_UNSPECIFIED; inlinable = false;