X86-64: Add -mskip-rax-setup
commit190466e05b492258d0f7c8cdcf3ff20c6520ee6b
authorhjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 18 Dec 2014 17:35:45 +0000 (18 17:35 +0000)
committerhjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 18 Dec 2014 17:35:45 +0000 (18 17:35 +0000)
tree7abe718095968d4646ff74e4b3831d0cae25c95b
parent7c260af35c2747206ee8b67c3722300ca72f483a
X86-64: Add -mskip-rax-setup

The Linux kernel never passes floating point arguments around, vararg
functions or not. Hence no vector registers are ever used when calling a
vararg function.  But gcc still dutifully emits an "xor %eax,%eax" before
each and every call of a vararg function.  Since no callee use that for
anything, these instructions are redundant.

This patch adds the -mskip-rax-setup option to skip setting up RAX
register when SSE is disabled and there are no variable arguments passed
in vector registers.  Since RAX register is used to avoid unnecessarily
saving vector registers on stack when passing variable arguments, the
impacts of this option are callees may waste some stack space, misbehave
or jump to a random location.  GCC 4.4 or newer don't those issues,
regardless the RAX register value since they don't check the RAX register
value when SSE is disabled.

gcc/

* config/i386/i386.c (ix86_expand_call): Skip setting up RAX
register for -mskip-rax-setup when there are no parameters
passed in vector registers.
* config/i386/i386.opt (mskip-rax-setup): New option.
* doc/invoke.texi: Document -mskip-rax-setup.

gcc/testsuite/

* gcc.target/i386/amd64-abi-7.c: New tests.
* gcc.target/i386/amd64-abi-8.c: Likwise.
* gcc.target/i386/amd64-abi-9.c: Likwise.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@218870 138bc75d-0d04-0410-961f-82ee72b054a4
gcc/ChangeLog
gcc/config/i386/i386.c
gcc/config/i386/i386.opt
gcc/doc/invoke.texi
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/amd64-abi-7.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/amd64-abi-8.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/amd64-abi-9.c [new file with mode: 0644]