It boils down to that -fno-plt should convert calling an external
function, foo, from
call foo@PLT
to
call *foo@GOT
to avoid one extra direct branch to PLT. The proper place for this is
in backend during expanding a function call. The backend already takes
care of many details for calling an external function, like setting up
a PIC register. Using the GOT slot instead of PLT slot is just one of
those details. For x86, it should be done in ix86_expand_call, not
prepare_call_address and hoping for the best, which doesn't always
happen. Also non-PIC case can only be handled in backend.
This patch reverts -fno-plt in prepare_call_address and handles it in
ix86_expand_call. Other backends may need similar changes to support
-fno-plt. Alternately, we can introduce a target hook to indicate
whether an external function should be called via register for -fno-plt
so that i386 backend can disable it in prepare_call_address.
sibcall_memory_operand is also updated to accept the GOT slot so that
call *foo@GOT(%reg)
can be generated by ix86_expand_call for 32-bit and 64-bit large model.
gcc/
PR target/67215
* calls.c (prepare_call_address): Don't handle -fno-plt here.
* config/i386/i386.c (ix86_expand_call): Generate indirect call
via GOT for -fno-plt. Support indirect call via GOT for x32.
gcc/testsuite/
PR target/67215
* gcc.target/i386/pr67215-1.c: New test.
* gcc.target/i386/pr67215-2.c: Likewise.
e091399...
by
jwlemke <jwlemke@138bc75d-0d04-0410-961f-82ee72b054a4>
5a7d537...
by
rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
2015-08-31 Richard Biener <email address hidden>
lto/
* lto.c (compare_tree_sccs_1): Compare DECL_ABSTRACT_ORIGIN.
* lto-symtab.c (lto_symtab_merge): Merge DECL_POSSIBLY_INLINED flag.
(lto_symtab_prevailing_decl): Do not replace a decl that didn't
participate in merging with something else.