From patchwork Tue Jun 15 14:18:43 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 55674 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 53983B7D6D for ; Wed, 16 Jun 2010 00:18:47 +1000 (EST) Received: (qmail 20920 invoked by alias); 15 Jun 2010 14:18:45 -0000 Received: (qmail 20910 invoked by uid 22791); 15 Jun 2010 14:18:44 -0000 X-SWARE-Spam-Status: No, hits=-6.1 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, 15 Jun 2010 14:18:37 +0000 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o5FEIZ7Q012657 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 15 Jun 2010 10:18:35 -0400 Received: from toil.yyz.redhat.com (toil.yyz.redhat.com [10.15.16.222]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o5FEIYoX017047 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 15 Jun 2010 10:18:35 -0400 Received: from toil.yyz.redhat.com (localhost.localdomain [127.0.0.1]) by toil.yyz.redhat.com (8.14.2/8.14.2) with ESMTP id o5FEIhC4027082; Tue, 15 Jun 2010 10:18:43 -0400 Received: (from aldyh@localhost) by toil.yyz.redhat.com (8.14.2/8.14.2/Submit) id o5FEIh7s027081; Tue, 15 Jun 2010 10:18:43 -0400 Date: Tue, 15 Jun 2010 10:18:43 -0400 From: Aldy Hernandez To: Patrick Marlier Cc: Richard Henderson , FELBER Pascal , gcc-patches@gcc.gnu.org Subject: Re: [trans-mem] undefined reference to a static cloned function Message-ID: <20100615141842.GA27062@redhat.com> References: <4BF3C398.9090407@unine.ch> <4BF4F6FC.1040204@unine.ch> <20100607134205.GA17619@redhat.com> <4C0D0507.1070200@unine.ch> <20100607174417.GA13762@redhat.com> <4C0F727F.4010709@unine.ch> <20100610133753.GA13188@redhat.com> <4C15D9D6.1080809@unine.ch> <4C167194.2090309@unine.ch> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <4C167194.2090309@unine.ch> User-Agent: Mutt/1.5.18 (2008-05-17) 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 have a testcase where the compiler can determine that it only needs the transactional version of a function, so the original function is not outputted, however we still dump the clone table entry. Ooops. I've put the original check back, since just checking the availability of the transactional clone will not do. Committing as obvious. * varasm.c (finish_tm_clone_pairs_1): Do not dump entry if the original function is not needed. Index: testsuite/gcc.dg/tm/20100615.c =================================================================== --- testsuite/gcc.dg/tm/20100615.c (revision 0) +++ testsuite/gcc.dg/tm/20100615.c (revision 0) @@ -0,0 +1,42 @@ +/* { dg-do compile } */ +/* { dg-options "-fgnu-tm -O" } */ + +/* Since the non TM version of new_node() gets optimized away, it + shouldn't appear in the clone table either. */ +/* { dg-final { scan-assembler-not "clone_table" } } */ + +#define NULL 0 +extern void *malloc (__SIZE_TYPE__); + +__attribute__((transaction_pure)) +void exit(int status); + +typedef struct node { +} node_t; + +__attribute__((transaction_safe)) +static node_t *new_node(node_t *next) +{ + node_t *node; + node = (node_t *)malloc(sizeof(node_t)); + if (node == NULL) { + exit(1); + } + return NULL; +} + +static node_t *set_new() +{ + node_t *min, *max; + __transaction [[atomic]] { + max = new_node(NULL); + min = new_node(max); + } + return min; +} + +int main(int argc, char **argv) +{ + set_new(); + return 0; +} Index: varasm.c =================================================================== --- varasm.c (revision 160590) +++ varasm.c (working copy) @@ -5850,6 +5850,7 @@ finish_tm_clone_pairs_1 (void **slot, vo bool *switched = (bool *) info; tree src = map->base.from; tree dst = map->to; + struct cgraph_node *src_n = cgraph_node (src); struct cgraph_node *dst_n = cgraph_node (dst); /* The function ipa_tm_create_version() marks the clone as needed if @@ -5861,6 +5862,11 @@ finish_tm_clone_pairs_1 (void **slot, vo if (!dst_n->needed) return 1; + /* This covers the case where we have optimized the original + function away, and only access the transactional clone. */ + if (!src_n->needed) + return 1; + if (!*switched) { switch_to_section (get_named_section (NULL, ".tm_clone_table", 3));