[RFC,X86_64] Eliminate PLT stubs for specified external functions via -fno-plt=
diff mbox

Message ID E7B625BD-C42E-4D36-B243-B49DA1F31FB1@gmail.com
State New
Headers show

Commit Message

Bernhard Reutner-Fischer June 2, 2015, 7:32 p.m. UTC
On June 2, 2015 8:15:42 PM GMT+02:00, Sriraman Tallam <tmsriram@google.com> 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.

Wrong order or && decl is redundant. Stopped reading here.

Thanks,

Patch
diff mbox

--- 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;