From patchwork Thu Jan 27 20:13:29 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 80730 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 91FBEB70EF for ; Fri, 28 Jan 2011 07:13:55 +1100 (EST) Received: (qmail 27147 invoked by alias); 27 Jan 2011 20:13:47 -0000 Received: (qmail 27111 invoked by uid 22791); 27 Jan 2011 20:13:38 -0000 X-SWARE-Spam-Status: No, hits=-6.4 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; Thu, 27 Jan 2011 20:13:33 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id p0RKDVHs004160 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 27 Jan 2011 15:13:32 -0500 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p0RKDUDt016293 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 27 Jan 2011 15:13:31 -0500 Received: from tyan-ft48-01.lab.bos.redhat.com (localhost.localdomain [127.0.0.1]) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4) with ESMTP id p0RKDU2t031014; Thu, 27 Jan 2011 21:13:30 +0100 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id p0RKDTLc030795; Thu, 27 Jan 2011 21:13:29 +0100 Date: Thu, 27 Jan 2011 21:13:29 +0100 From: Jakub Jelinek To: Jeff Law Cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH] Unshare constants in the constant pool (PR target/42894) Message-ID: <20110127201329.GP2724@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek References: <20110126193731.GK2724@tyan-ft48-01.lab.bos.redhat.com> <4D40CA75.4060108@redhat.com> <20110127084800.GM2724@tyan-ft48-01.lab.bos.redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20110127084800.GM2724@tyan-ft48-01.lab.bos.redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes 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 On Thu, Jan 27, 2011 at 09:48:00AM +0100, Jakub Jelinek wrote: > On Wed, Jan 26, 2011 at 06:29:25PM -0700, Jeff Law wrote: > > Well, one could easily argue that using the original expression in the > > REG_EQUAL note is incorrect as well. In fact, looking over all the > > calls to set_unique_reg_note shows that most either copy the value or > > generate a new one. > > > > I think that means we actually want both the varasm.c and the expr.c > > change to avoid incorrect sharing. > > I think the reason why most of the set_unique_reg_note calls copy_rtx > is that the pattern is usually kept in the insn (or in some other insn). > In the emit_move_insn case it specifically tests that the pattern is not > there (well, some weird target could embed it in some unspec or something), > the reason I changed force_const_mem was to deal with any other uses of > force_const_mem. > > But I guess if you strongly prefer to have it in both places I can test a > patch. This passed bootstrap/regtest on x86_64-linux and i686-linux too: 2011-01-27 Jakub Jelinek PR target/42894 * varasm.c (force_const_mem): Store copy of x in desc->constant instead of x itself. * expr.c (emit_move_insn): Add a copy of y_cst instead of y_cst itself into REG_EQUAL note. * gcc.dg/tls/pr42894.c: New test. Jakub --- gcc/varasm.c.jj 2011-01-25 12:58:41.000000000 +0100 +++ gcc/varasm.c 2011-01-26 14:07:50.635389932 +0100 @@ -3518,7 +3518,7 @@ force_const_mem (enum machine_mode mode, pool->offset &= ~ ((align / BITS_PER_UNIT) - 1); desc->next = NULL; - desc->constant = tmp.constant; + desc->constant = copy_rtx (tmp.constant); desc->offset = pool->offset; desc->hash = hash; desc->mode = mode; --- gcc/expr.c.jj 2011-01-26 14:07:50.635389932 +0100 +++ gcc/expr.c 2011-01-27 17:05:04.936795133 +0100 @@ -3398,7 +3398,7 @@ emit_move_insn (rtx x, rtx y) && (set = single_set (last_insn)) != NULL_RTX && SET_DEST (set) == x && ! rtx_equal_p (y_cst, SET_SRC (set))) - set_unique_reg_note (last_insn, REG_EQUAL, y_cst); + set_unique_reg_note (last_insn, REG_EQUAL, copy_rtx (y_cst)); return last_insn; } --- gcc/testsuite/gcc.dg/tls/pr42894.c.jj 2011-01-26 16:29:13.765389223 +0100 +++ gcc/testsuite/gcc.dg/tls/pr42894.c 2011-01-26 16:31:46.830433380 +0100 @@ -0,0 +1,12 @@ +/* PR target/42894 */ +/* { dg-do compile } */ +/* { dg-options "-march=armv5te -mthumb" { target arm*-*-* } } */ +/* { dg-require-effective-target tls } */ + +extern __thread int t; + +void +foo (int a) +{ + t = a; +}