This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [RFC][PATCH][X86_64] Eliminate PLT stubs for specified external functions via -fno-plt=
- From: Richard Henderson <rth at redhat dot com>
- To: Sriraman Tallam <tmsriram at google dot com>, Ramana Radhakrishnan <ramana dot radhakrishnan at arm dot com>
- Cc: Jan Hubicka <hubicka at ucw dot cz>, "H.J. Lu" <hjl dot tools at gmail dot com>, Pedro Alves <palves at redhat dot com>, Michael Matz <matz at suse dot de>, David Li <davidxl at google dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 03 Jun 2015 13:09:40 -0700
- Subject: Re: [RFC][PATCH][X86_64] Eliminate PLT stubs for specified external functions via -fno-plt=
- Authentication-results: sourceware.org; auth=none
- References: <CAMe9rOrCh++A=jLOcDVXGM+UOyn31kuJ+R5ZmZkw8E_eHmCTHQ at mail dot gmail dot com> <20150529193552 dot GA52215 at kam dot mff dot cuni dot cz> <CAAs8Hmxg2a77HdJuedSkO8EkfROvSx_V2VOcZtWUAEiXLC3G6g at mail dot gmail dot com> <CAJA7tRYsMiq7rx34c=z6KwRdwYxxaeP6Z6qzA4XEwnJSMT7z=Q at mail dot gmail dot com> <CAAs8HmxB9NyJQHRxTLj4gKntDgwFfri0VvwSR6vfA1HDTpFHaQ at mail dot gmail dot com> <556C16B1 dot 5080606 at arm dot com> <CAAs8Hmy3jZDkE1hNmojx9rBBAZ9tjCYHXHevojMTAYHZ5kp8hA at mail dot gmail dot com> <CAJA7tRbHAHi7i1xboTZadrJLE_Ry628pwLot6f3wdK4KzawqCQ at mail dot gmail dot com> <CAAs8Hmy6gFfoKrVWJ2tCWQZ6Lkez2DCikWozVgwFcY-peDtOhw at mail dot gmail dot com> <CAJA7tRYUMvHt04m-+uM9irXRXC57iV9pP0jqQKoj9AJ+rwuo2g at mail dot gmail dot com> <CAAs8HmzcD4-t2bbxVL93PSU-1Mp-AZ=Qd-JN8mmjw6pC1Q+h9g at mail dot gmail dot com> <CAJA7tRYJxSGNyrrVw4JCBaUF2bgM0UaJ_+Md-DNLDdKZHUxAYg at mail dot gmail dot com> <CAAs8HmxdA5Fa7Lu4UzQS_nkFuQNW=4zvv21ucAS3iMQp=OM+8w at mail dot gmail dot com> <556F0EBF.90! 30005 at arm .com> <CAAs8Hmy5RXk89ea=uxHip-t0-2J2-2PTo_y0uGqrvyCFb1oqnw at mail dot gmail dot com>
On 06/03/2015 11:38 AM, Sriraman Tallam wrote:
> + { "no_plt", 0, 0, true, false, false,
> + handle_no_plt_attribute, false },
Call it noplt. We don't add the underscore for noinline, noclone, etc.
> Index: config/i386/i386.c
> ===================================================================
> --- config/i386/i386.c (revision 223720)
> +++ config/i386/i386.c (working copy)
> @@ -5479,7 +5479,10 @@ ix86_function_ok_for_sibcall (tree decl, tree exp)
> && !TARGET_64BIT
> && flag_pic
> && flag_plt
> - && decl && !targetm.binds_local_p (decl))
> + && decl
> + && (TREE_CODE (decl) != FUNCTION_DECL
> + || !lookup_attribute ("no_plt", DECL_ATTRIBUTES (decl)))
> + && !targetm.binds_local_p (decl))
> return false;
>
> /* If we need to align the outgoing stack, then sibcalling would
Is this really necessary? I'd expect DECL to be NULL in this case,
since the non-use of the PLT will mean that the (sib)call is indirect.
> @@ -25497,13 +25500,19 @@ ix86_expand_call (rtx retval, rtx fnaddr, rtx call
> }
> else
> {
> - /* Static functions and indirect calls don't need the pic register. */
> + /* Static functions and indirect calls don't need the pic register. Also,
> + check if PLT was explicitly avoided via no-plt or "no_plt" attribute, making
> + it an indirect call. */
> if (flag_pic
> && (!TARGET_64BIT
> || (ix86_cmodel == CM_LARGE_PIC
> && DEFAULT_ABI != MS_ABI))
> && GET_CODE (XEXP (fnaddr, 0)) == SYMBOL_REF
> - && ! SYMBOL_REF_LOCAL_P (XEXP (fnaddr, 0)))
> + && !SYMBOL_REF_LOCAL_P (XEXP (fnaddr, 0))
> + && flag_plt
> + && (TREE_CODE (SYMBOL_REF_DECL (XEXP(fnaddr, 0))) != FUNCTION_DECL
> + || !lookup_attribute ("no_plt",
> + DECL_ATTRIBUTES (SYMBOL_REF_DECL (XEXP(fnaddr, 0))))))
> {
> use_reg (&use, gen_rtx_REG (Pmode, REAL_PIC_OFFSET_TABLE_REGNUM));
> if (ix86_use_pseudo_pic_reg ())
Why are you testing FUNCTION_DECL? Even if, somehow, the user were producing a
function call to a data symbol, why do you think that lookup_attribute would
produce incorrect results?
Similarly in ix86_nopic_no_plt_attribute_p.
r~