From patchwork Fri May 25 13:25:47 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 161346 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 13206B6F6E for ; Fri, 25 May 2012 23:26:10 +1000 (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=1338557171; 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=9pnX63j JNTM8SNxq5N2yz+xS+rc=; b=Z7Q5ehR11GD56B6fvM5PKfGNmbqPADNGRaQpwo7 l3mf+xbccfJaBndr//xlbKaIpMJoBN0seUe4urpNHFysxxF9VUH7rI/4SP42zaRM YKSrLv4Y0ZQqTjvWgXnMqMmm2H+1EaCej8NswqYLoOzl86rpuLU2UV3nvC0Al9Gx JlnA= 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=dP3cAnAj526CSq0cROPp22J2rs0zTgHA44lV5qMr8QW/jLwQaq8TfUX6KYUq1O haeCsBgN+P2pvvTCdJ73/wkPpaVcs47O0XVmTrvqP6zdiSUvenujWU1LSkzC4Fxo +AsL1eKVrXuVCzZYFcrjcgZlkQyCGFToteBfIgES2OsXA=; Received: (qmail 30072 invoked by alias); 25 May 2012 13:26:07 -0000 Received: (qmail 30062 invoked by uid 22791); 25 May 2012 13:26:06 -0000 X-SWARE-Spam-Status: No, hits=-6.3 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, 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; Fri, 25 May 2012 13:25:49 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q4PDPmOK030644 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 25 May 2012 09:25:48 -0400 Received: from houston.quesejoda.com (vpn-231-145.phx2.redhat.com [10.3.231.145]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q4PDPlD2008166; Fri, 25 May 2012 09:25:48 -0400 Message-ID: <4FBF885B.9000809@redhat.com> Date: Fri, 25 May 2012 08:25:47 -0500 From: Aldy Hernandez User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20120430 Thunderbird/12.0.1 MIME-Version: 1.0 To: Richard Henderson CC: gcc-patches , MARLIER Patrick , daveboutcher@gmail.com Subject: PR middle-end/53008 (trans-mem): output clone if function accessed indirectly 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 This is a patch from Patrick, based on an earlier patch by Dave Boutcher. Thanks folks. In the failing testcase below we have a transaction_safe function being accessed indirectly, but for -O1 and above, the corresponding clone is not generated because we think it is unused. Fixed by forcing the clone output if it is accessed indirectly. Tested on x86-64 Linux. OK? Would this be acceptable for the 4.7 branch as well? PR middle-end/53008 * trans-mem.c (ipa_tm_create_version_alias): Output new_node if accessed indirectly. (ipa_tm_create_version): Same. Index: testsuite/gcc.dg/tm/pr53008.c =================================================================== --- testsuite/gcc.dg/tm/pr53008.c (revision 0) +++ testsuite/gcc.dg/tm/pr53008.c (revision 0) @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-fgnu-tm -O" } */ + +void __attribute__((transaction_safe)) (*fn)(void); + +static void __attribute__((transaction_safe)) +foo(void) +{ +} + +void set_fn(void) +{ + fn = foo; +} Index: trans-mem.c =================================================================== --- trans-mem.c (revision 187729) +++ trans-mem.c (working copy) @@ -4328,7 +4328,8 @@ ipa_tm_create_version_alias (struct cgra record_tm_clone_pair (old_decl, new_decl); - if (info->old_node->symbol.force_output) + if (info->old_node->symbol.force_output + || ipa_ref_list_first_referring (&info->old_node->symbol.ref_list)) ipa_tm_mark_force_output_node (new_node); return false; } @@ -4381,7 +4382,8 @@ ipa_tm_create_version (struct cgraph_nod record_tm_clone_pair (old_decl, new_decl); cgraph_call_function_insertion_hooks (new_node); - if (old_node->symbol.force_output) + if (old_node->symbol.force_output + || ipa_ref_list_first_referring (&old_node->symbol.ref_list)) ipa_tm_mark_force_output_node (new_node); /* Do the same thing, but for any aliases of the original node. */