From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17171 invoked by alias); 2 Jun 2015 21:18:26 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 17159 invoked by uid 89); 2 Jun 2015 21:18:25 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=1.0 required=5.0 tests=AWL,BAYES_50,FREEMAIL_FROM,KAM_STOCKGEN,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=no version=3.3.2 X-HELO: mail-wi0-f182.google.com Received: from mail-wi0-f182.google.com (HELO mail-wi0-f182.google.com) (209.85.212.182) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Tue, 02 Jun 2015 21:18:24 +0000 Received: by wifw1 with SMTP id w1so160766087wif.0 for ; Tue, 02 Jun 2015 14:18:21 -0700 (PDT) X-Received: by 10.194.175.65 with SMTP id by1mr55655825wjc.152.1433279901471; Tue, 02 Jun 2015 14:18:21 -0700 (PDT) Received: from [10.41.147.71] (089144219071.atnat0028.highway.a1.net. [89.144.219.71]) by mx.google.com with ESMTPSA id v3sm23433000wiz.14.2015.06.02.14.18.19 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Jun 2015 14:18:20 -0700 (PDT) User-Agent: K-9 Mail for Android In-Reply-To: References: <20150529193552.GA52215@kam.mff.cuni.cz> <556C16B1.5080606@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Subject: Re: [RFC][PATCH][X86_64] Eliminate PLT stubs for specified external functions via -fno-plt= From: Bernhard Reutner-Fischer Date: Tue, 02 Jun 2015 21:18:00 -0000 To: Sriraman Tallam CC: ramrad01@arm.com,Ramana Radhakrishnan ,Jan Hubicka ,"H.J. Lu" ,Pedro Alves ,Michael Matz ,David Li ,GCC Patches Message-ID: <35E96DE2-8502-421E-BB43-0A84F65E94AB@gmail.com> X-IsSubscribed: yes X-SW-Source: 2015-06/txt/msg00253.txt.bz2 On June 2, 2015 9:59:40 PM GMT+02:00, Sriraman Tallam wrote: >On Tue, Jun 2, 2015 at 12:32 PM, Bernhard Reutner-Fischer > wrote: >> On June 2, 2015 8:15:42 PM GMT+02:00, Sriraman Tallam > wrote: >> [] >> >>>I have now modified this patch. >>> >>>This patch does two things: >>> >>>1) Adds new generic function attribute "no_plt" that is similar in >>>functionality to -fno-plt except that it applies only to calls to >>>functions that are marked with this attribute. >>>2) For x86_64, it makes -fno-plt(and the attribute) also work for >>>non-PIC code by directly generating an indirect call via a GOT >entry. >>> >>>For PIC code, no_plt merely shadows the implementation of -fno-plt, >no >>>surprises here. >>> >>>* c-family/c-common.c (no_plt): New attribute. >>>(handle_no_plt_attribute): New handler. >>>* calls.c (prepare_call_address): Check for no_plt >>>attribute. >>>* config/i386/i386.c (ix86_function_ok_for_sibcall): Check >>>for no_plt attribute. >>>(ix86_expand_call): Ditto. >>>(nopic_no_plt_attribute): New function. >>>(ix86_output_call_insn): Output indirect call for non-pic >>>no plt calls. >>>* doc/extend.texi (no_plt): Document new attribute. >>>* testsuite/gcc.target/i386/noplt-1.c: New test. >>>* testsuite/gcc.target/i386/noplt-2.c: New test. >>>* testsuite/gcc.target/i386/noplt-3.c: New test. >>>* testsuite/gcc.target/i386/noplt-4.c: New test. >>> >>> >>>Please review. >> >> --- config/i386/i386.c (revision 223720) >> +++ config/i386/i386.c (working copy) >> @@ -5479,6 +5479,8 @@ ix86_function_ok_for_sibcall (tree decl, tree >exp) >> && !TARGET_64BIT >> && flag_pic >> && flag_plt >> + && (TREE_CODE (decl) != FUNCTION_DECL >> + || !lookup_attribute ("no_plt", DECL_ATTRIBUTES (decl))) >> && decl && !targetm.binds_local_p (decl)) >> return false; >> >> Wrong order or && decl is redundant. Stopped reading here. > >Fixed and new patch Just reading the diff I do not grok the different conditions in ix86_function_ok_for_sibcall ix86_expand_call especially regarding CM_LARGE_PIC but I take it you've read more context. - && ! SYMBOL_REF_LOCAL_P (XEXP (fnaddr, 0))) + && ! SYMBOL_REF_LOCAL_P (XEXP (fnaddr, 0)) + && flag_plt s/! /!/;# while you touch or maybe that's OK -- check_GNU.sh would know, hopefully. +/* Return true if the function being called was marked with attribute + "no_plt" or using -fno-plt and we are compiling for no-PIC and x86_64. + This is currently used only with 64-bit ELF targets to call the function a function + marked "no_plt" indirectly. */ + +static bool +nopic_no_plt_attribute (rtx call_op) IIRC predicates ought to have a _p suffix but maybe that's outdated nowadays? +{ + if (flag_pic) + return false; + + if (!TARGET_64BIT || TARGET_MACHO|| TARGET_SEH || TARGET_PECOFF) missing space after || We have a contrib/check*.sh style checker for patches in there. + return false; + + if (SYMBOL_REF_LOCAL_P (call_op)) + return false; + + tree symbol_decl = SYMBOL_REF_DECL (call_op); + + if (symbol_decl != NULL_TREE + && TREE_CODE (symbol_decl) == FUNCTION_DECL + && (!flag_plt + || lookup_attribute ("no_plt", DECL_ATTRIBUTES (symbol_decl)))) + return true; + + return false; +} +@item no_plt +@cindex @code{no_plt} function attribute +The @code{no_plt} attribute is used to inform the compiler that a calls Doesn't parse. a call / calls +to the function should not use the PLT. For example, external functions would be nice to have an xref to PLT definition for the casual reader, iff we have one or could have one easily. +defined in shared objects are called from the executable using the PLT. +This attribute on the function declaration calls these functions indirectly +rather than going via the PLT. This is similar to @option{-fno-plt} but +is only applicable to calls to the function marked with this attribute. + smallexample (or you-name-it counterpart) for code-avoidance for bonus points, maybe. Not a conceptual review due to current cellphone-impairedness, but looks somewhat plausible at first glance.. HTH && cheers,