From patchwork Thu Sep 23 11:26:40 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Modra X-Patchwork-Id: 65528 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 214B8B70DC for ; Thu, 23 Sep 2010 21:27:00 +1000 (EST) Received: (qmail 5007 invoked by alias); 23 Sep 2010 11:26:58 -0000 Received: (qmail 4994 invoked by uid 22791); 23 Sep 2010 11:26:57 -0000 X-SWARE-Spam-Status: No, hits=-1.3 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE X-Spam-Check-By: sourceware.org Received: from mail-pw0-f47.google.com (HELO mail-pw0-f47.google.com) (209.85.160.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 23 Sep 2010 11:26:53 +0000 Received: by pwi10 with SMTP id 10so221607pwi.20 for ; Thu, 23 Sep 2010 04:26:48 -0700 (PDT) Received: by 10.114.109.10 with SMTP id h10mr1661532wac.53.1285241208035; Thu, 23 Sep 2010 04:26:48 -0700 (PDT) Received: from bubble.grove.modra.org ([115.187.252.19]) by mx.google.com with ESMTPS id d2sm1202054wam.2.2010.09.23.04.26.44 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 23 Sep 2010 04:26:45 -0700 (PDT) Received: by bubble.grove.modra.org (Postfix, from userid 1000) id 7514B170C206; Thu, 23 Sep 2010 20:56:40 +0930 (CST) Date: Thu, 23 Sep 2010 20:56:40 +0930 From: Alan Modra To: gcc-patches@gcc.gnu.org, David Edelsohn Subject: Re: PowerPC64 large toc model Message-ID: <20100923112640.GB16376@bubble.grove.modra.org> Mail-Followup-To: gcc-patches@gcc.gnu.org, David Edelsohn References: <20100608125703.GI7312@bubble.grove.modra.org> <20100625104301.GI21855@bubble.grove.modra.org> <20100906121133.GL16874@bubble.grove.modra.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20100906121133.GL16874@bubble.grove.modra.org> User-Agent: Mutt/1.5.20 (2009-06-14) 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 I'm a little embarassed to admit that the hack I put in with the aim of better supporting non-fPIC shared libs on powerpc64 is almost completely useless. The thing is that -fsection-anchors, on by default, results in non-fPIC shared libs that won't support overriding of global vars anyway. So there isn't much point in avoiding an -mcmodel=medium optimisation. Bootstrapped etc. powerpc64-linux, OK'd offline by David. * config/rs6000/rs6000.c (toc_relative_ok): Delete. (rs6000_emit_move): Use SYMBOL_REF_LOCAL_P instead. Index: gcc/config/rs6000/rs6000.c =================================================================== --- gcc/config/rs6000/rs6000.c (revision 164538) +++ gcc/config/rs6000/rs6000.c (working copy) @@ -7032,46 +7032,6 @@ rs6000_eliminate_indexed_memrefs (rtx op copy_addr_to_reg (XEXP (operands[1], 0))); } -/* Return true if OP, a SYMBOL_REF, should be considered local when - generating -mcmodel=medium code. */ - -static bool -toc_relative_ok (rtx op) -{ - tree decl; - - if (!SYMBOL_REF_LOCAL_P (op)) - return false; - - /* This is a bit hard to explain. When building shared libraries, - you are supposed to pass -fpic or -fPIC to the compiler. - -fpic/-fPIC not only generate position independent code but also - generate code that supports ELF shared library global function - or variable overriding. ppc64 is always PIC and at least some of - the ELF shared libaray semantics of global variables happen to be - supported without -fpic/-fPIC. So people may not be careful - about using -fPIC for shared libs. - With -mcmodel=medium this situation changes. A shared library - built without -fpic/-fPIC requires text relocs for global var - access (and would fail to load since glibc ld.so doesn't support - the required dynamic relocs). So avoid this potential - problem by using -mcmodel=large access for global vars, unless - we know we are compiling for an executable. */ - if (flag_pie) - return true; - - decl = SYMBOL_REF_DECL (op); - if (!decl || !DECL_P (decl)) - return true; - if (!TREE_PUBLIC (decl)) - return true; - if (DECL_VISIBILITY (decl) != VISIBILITY_DEFAULT) - return true; - - /* If we get here we must have a global var. See binds_local_p. */ - return flag_whole_program; -} - /* Return true if memory accesses to DECL are known to never straddle a 32k boundary. */ @@ -7427,7 +7387,7 @@ rs6000_emit_move (rtx dest, rtx source, || (TARGET_CMODEL == CMODEL_MEDIUM && GET_CODE (operands[1]) == SYMBOL_REF && !CONSTANT_POOL_ADDRESS_P (operands[1]) - && toc_relative_ok (operands[1]) + && SYMBOL_REF_LOCAL_P (operands[1]) && offsettable_ok_by_alignment (SYMBOL_REF_DECL (operands[1])))) { rtx reg = NULL_RTX;