Properly handle -fno-plt in ix86_expand_call
commitf42bf19f00d5a3626e7874b3a07bd645ca6677e9
authorhjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 27 Oct 2015 14:29:31 +0000 (27 14:29 +0000)
committerhjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 27 Oct 2015 14:29:31 +0000 (27 14:29 +0000)
tree7857a8fb40fac9dc1241869f80d69f38b3cba602
parent25359ccf72c395330df7303ecfdfbf42229c6512
Properly handle -fno-plt in ix86_expand_call

prepare_call_address in calls.c is the wrong place to handle -fno-plt.
We shoudn't force function address into register and hope that load
function address via GOT and indirect call via register will be folded
into indirect call via GOT, which doesn't always happen.  Also non-PIC
case can only be handled in backend.  Instead, backend should expand
external function call into indirect call via GOT for -fno-plt.

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.

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.
* config/i386/predicates.md (sibcall_memory_operand): Allow
GOT memory operand.

gcc/testsuite/

PR target/67215
* gcc.target/i386/pr67215-1.c: New test.
* gcc.target/i386/pr67215-2.c: Likewise.
* gcc.target/i386/pr67215-3.c: Likewise.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@229444 138bc75d-0d04-0410-961f-82ee72b054a4
gcc/ChangeLog
gcc/calls.c
gcc/config/i386/i386.c
gcc/config/i386/predicates.md
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/pr67215-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/pr67215-2.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/pr67215-3.c [new file with mode: 0644]