From patchwork Wed Jan 26 19:37:31 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 80544 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 0A7E9B7124 for ; Thu, 27 Jan 2011 06:37:41 +1100 (EST) Received: (qmail 9753 invoked by alias); 26 Jan 2011 19:37:40 -0000 Received: (qmail 9734 invoked by uid 22791); 26 Jan 2011 19:37:39 -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; Wed, 26 Jan 2011 19:37:34 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id p0QJbWmR007725 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 26 Jan 2011 14:37:32 -0500 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p0QJbVtC021325 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 26 Jan 2011 14:37:32 -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 p0QJbVYK013297 for ; Wed, 26 Jan 2011 20:37:31 +0100 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id p0QJbV7I013296 for gcc-patches@gcc.gnu.org; Wed, 26 Jan 2011 20:37:31 +0100 Date: Wed, 26 Jan 2011 20:37:31 +0100 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Subject: [PATCH] Unshare constants in the constant pool (PR target/42894) Message-ID: <20110126193731.GK2724@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline 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 Hi! As discussed in the PR, if a non-shareable constant is force_const_mem and the original expression is used elsewhere in the IL (e.g. in REG_EQUAL or REG_EQUIV note), unshare_all_rtl doesn't unshare it, but modification of the IL might result in changes of the constant in theory and if avoid_constant_pool_reference result is then pushed somewhere else into the IL, we get RTL sharing errors (as on arm on this testcase). Bootstrapped/regtested on x86_64-linux and i686-linux, ok if it passes bootstrap/regtest also on arm? 2011-01-26 Jakub Jelinek PR target/42894 * varasm.c (force_const_mem): Store copy of x in desc->constant instead of x itself. * 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/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; +}