[PATCH] Use call-clobbered register for sibcall via GOT
authorH.J. Lu <hongjiu.lu@intel.com>
Tue, 22 Dec 2015 15:38:25 +0000 (15:38 +0000)
committerUros Bizjak <uros@gcc.gnu.org>
Tue, 22 Dec 2015 15:38:25 +0000 (16:38 +0100)
commitaf9345d7df615812a078bb942cadd4c317c3e3de
tree50dc8240bb2cdb582ac0bdae2f5b1ce15d0be998
parentfda5652f8fe24f637b29608d12fff72e6df08ba9
[PATCH] Use call-clobbered register for sibcall via GOT

From: H.J. Lu  <hongjiu.lu@intel.com>

Since sibcall never returns, we can only use call-clobbered register as
GOT base.  Otherwise, callee-saved register used as GOT base won't be
properly restored.  sibcall_memory_operand is changed to allow 32-bit
GOT slot only with pseudo register as GOT base for RTL expansion.  2
new patterns, *sibcall_GOT_32 and *sibcall_value_GOT_32, are added to
expose GOT base register to register allocator so that call-clobbered
register will be used for GOT base.

gcc/

PR target/68937
* config/i386/i386.c (ix86_function_ok_for_sibcall): Count
call to global function via GOT slot as indirect call.
* config/i386/i386.md (*sibcall_GOT_32): New pattern.
(*sibcall_value_GOT_32): Likewise.
* config/i386/predicates.md (sibcall_memory_operand): Rewrite.
Allow 32-bit GOT slot only with pseudo register as GOT base.
(GOT32_symbol_operand): New predicate.

gcc/testsuite/

PR target/68937
* gcc.target/i386/pr68937-1.c: New test.
* gcc.target/i386/pr68937-2.c: Likewise.
* gcc.target/i386/pr68937-3.c: Likewise.
* gcc.target/i386/pr68937-4.c: Likewise.
* gcc.target/i386/pr68937-5.c: Likewise.
* gcc.target/i386/pr68937-6.c: Likewise.

From-SVN: r231903
gcc/ChangeLog
gcc/config/i386/i386.c
gcc/config/i386/i386.md
gcc/config/i386/predicates.md
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/pr68937-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/pr68937-2.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/pr68937-3.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/pr68937-4.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/pr68937-5.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/pr68937-6.c [new file with mode: 0644]