From patchwork Tue Aug 13 19:47:10 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 266911 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]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 56A6C2C0106 for ; Wed, 14 Aug 2013 05:47:22 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:reply-to:mime-version :content-type; q=dns; s=default; b=vyEXTMUhFjE5JDKeToHzIonoNzd2g OCvL58AMiA5nPVfuIIbn/MYTAzM2RKiEuOtsrJMzHY6Wctz7tEgT9Ao17OzovkDI jnvZLeIPmD2DNFwS1B96gU4bULFsxIA27TNZ1059moo69ZGUZadntX5Rq4C37bjf lEhxvCWVvZnEHU= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:reply-to:mime-version :content-type; s=default; bh=Xm77xJ6tCMPBq92foPw9bdykeE8=; b=vXd nZta8t74n0E6KRLxt4FCxSyigjTnJWZoR7xmcG3u1o7UdNqQCwI0hwjwgaC4vUsw 5ynDvtdc+TPA0hz40/hAcncp6TuHp+V/VtSdPXTMgD+bnPK/WYh2Qc9sB5hzLmjw Tf4SaKb2ddiZuboNDqOcOlz6CRShaVI33YoZegOo= Received: (qmail 5246 invoked by alias); 13 Aug 2013 19:47:16 -0000 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 Received: (qmail 5224 invoked by uid 89); 13 Aug 2013 19:47:15 -0000 X-Spam-SWARE-Status: No, score=-7.6 required=5.0 tests=AWL, BAYES_00, RCVD_IN_HOSTKARMA_W, RCVD_IN_HOSTKARMA_WL, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Tue, 13 Aug 2013 19:47:14 +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 r7DJlDEk011482 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 13 Aug 2013 15:47:13 -0400 Received: from zalov.cz (vpn1-7-79.ams2.redhat.com [10.36.7.79]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r7DJlBZb022350 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 13 Aug 2013 15:47:12 -0400 Received: from zalov.cz (localhost [127.0.0.1]) by zalov.cz (8.14.5/8.14.5) with ESMTP id r7DJlAG1018310; Tue, 13 Aug 2013 21:47:10 +0200 Received: (from jakub@localhost) by zalov.cz (8.14.5/8.14.5/Submit) id r7DJlAX0018309; Tue, 13 Aug 2013 21:47:10 +0200 Date: Tue, 13 Aug 2013 21:47:10 +0200 From: Jakub Jelinek To: Uros Bizjak , Richard Henderson Cc: gcc-patches@gcc.gnu.org, Alexandre Oliva Subject: [PATCH] x86_64 -mcmodel={medium, large} -fpic address delegitimization Message-ID: <20130813194710.GK1814@tucnak.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Hi! On x86_64 with -mcmodel=large -fpic -g -O2 we get tons of notes about non-delegitimized unspecs like UNSPEC_GOTOFF, UNSPEC_PLTOFF or UNSPEC_GOT. Seems we already handle most of those properly for -m32 code, so the issue is just that we wouldn't fall back into the -m32 handling code which takes care of dealing with addends, missing pic pointer etc. The following patch inverts the last condition for TARGET_64BIT code and falls through for CM_MEDIUM_PIC and CM_LARGE_PIC cmodels. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2013-08-13 Jakub Jelinek Alexandre Oliva PR target/58067 * config/i386/i386.c (ix86_delegitimize_address): For CM_MEDIUM_PIC and CM_LARGE_PIC ix86_cmodel fall thru into the -m32 code, handle there also UNSPEC_PLTOFF. Jakub --- gcc/config/i386/i386.c.jj 2013-08-13 14:42:32.000000000 +0200 +++ gcc/config/i386/i386.c 2013-08-13 18:49:25.514219094 +0200 @@ -14135,21 +14135,29 @@ ix86_delegitimize_address (rtx x) x = replace_equiv_address_nv (orig_x, x); return x; } - if (GET_CODE (x) != CONST - || GET_CODE (XEXP (x, 0)) != UNSPEC - || (XINT (XEXP (x, 0), 1) != UNSPEC_GOTPCREL - && XINT (XEXP (x, 0), 1) != UNSPEC_PCREL) - || (!MEM_P (orig_x) && XINT (XEXP (x, 0), 1) != UNSPEC_PCREL)) - return ix86_delegitimize_tls_address (orig_x); - x = XVECEXP (XEXP (x, 0), 0, 0); - if (GET_MODE (orig_x) != GET_MODE (x) && MEM_P (orig_x)) + + if (GET_CODE (x) == CONST + && GET_CODE (XEXP (x, 0)) == UNSPEC + && (XINT (XEXP (x, 0), 1) == UNSPEC_GOTPCREL + || XINT (XEXP (x, 0), 1) == UNSPEC_PCREL) + && (MEM_P (orig_x) || XINT (XEXP (x, 0), 1) == UNSPEC_PCREL)) { - x = simplify_gen_subreg (GET_MODE (orig_x), x, - GET_MODE (x), 0); - if (x == NULL_RTX) - return orig_x; + x = XVECEXP (XEXP (x, 0), 0, 0); + if (GET_MODE (orig_x) != GET_MODE (x) && MEM_P (orig_x)) + { + x = simplify_gen_subreg (GET_MODE (orig_x), x, + GET_MODE (x), 0); + if (x == NULL_RTX) + return orig_x; + } + return x; } - return x; + + if (ix86_cmodel != CM_MEDIUM_PIC && ix86_cmodel != CM_LARGE_PIC) + return ix86_delegitimize_tls_address (orig_x); + + /* Fall thru into the code shared with -m32 for -mcmodel=large -fpic + and -mcmodel=medium -fpic. */ } if (GET_CODE (x) != PLUS @@ -14186,10 +14194,12 @@ ix86_delegitimize_address (rtx x) if (GET_CODE (x) == UNSPEC && ((XINT (x, 1) == UNSPEC_GOT && MEM_P (orig_x) && !addend) - || (XINT (x, 1) == UNSPEC_GOTOFF && !MEM_P (orig_x)))) + || (XINT (x, 1) == UNSPEC_GOTOFF && !MEM_P (orig_x)) + || (XINT (x, 1) == UNSPEC_PLTOFF && ix86_cmodel == CM_LARGE_PIC + && !MEM_P (orig_x) && !addend))) result = XVECEXP (x, 0, 0); - if (TARGET_MACHO && darwin_local_data_pic (x) + if (!TARGET_64BIT && TARGET_MACHO && darwin_local_data_pic (x) && !MEM_P (orig_x)) result = XVECEXP (x, 0, 0);