x86/Rules: Use -mskip-rax-setup if the compiler supports it
PATCH 1/1 x86/Rules: Use -mskip-rax-setup if the compiler supports it
This option is available from GCC 5 onwards, and was specifically introduced as an optimisation for Linux. When using varadic functions, the caller needs to know how many floating point arguments were passed. Xen, like Linux, doesn't uses floating point arguments, so doesn't need to emit code to inform varadic functions such as printk() that there are zero arguments.
The net delta for a release build is:
add/remove: 0/0 grow/shrink: 35/625 up/down: 603/-5489 (-4886)
with the single biggest change being:
x86_emulate 101933 101751 -182
---
CC: Jan Beulich <[email protected]>
--- xen/arch/x86/Rules.mk | 4 ++++ 1 file changed, 4 insertions(+)
xen/arch/x86/Rules.mk +4 -0
@@ -30,3 +30,7 @@ CFLAGS += -fno-asynchronous-unwind-tables ifneq ($(call cc-option,$(CC),-fvisibility=hidden,n),n) CFLAGS += -DGCC_HAS_VISIBILITY_ATTRIBUTE endif + +# Xen doesn't ever pass SSE arguments. Discard the SSE setup +# (i.e. `xor %eax, %eax`) before varadic function calls if possible. +$(call cc-option-add,CFLAGS,CC,-mskip-rax-setup)
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 08.01.18 at 11:46, <[email protected]> wrote:
This option is available from GCC 5 onwards, and was specifically introduced as an optimisation for Linux. When using varadic functions, the caller needs
to know how many floating point arguments were passed. Xen, like Linux, doesn't uses floating point arguments, so doesn't need to emit code to inform
varadic functions such asprintk()that there are zero arguments.
Quoted 7 lines
The net delta for a release build is:
add/remove: 0/0 grow/shrink: 35/625 up/down: 603/-5489 (-4886)
with the single biggest change being:
x86_emulate101933 101751 -182
What variadic function(s) are being used there? I can spot a couple of calls to printk() and one call to cpu_has_amd_erratum(), but that can hardly account to 182 saved bytes.
xen/arch/x86/Rules.mk CFLAGS += -fno-asynchronous-unwind-tables · line 36
Quoted 10 lines
xen/arch/x86/Rules.mk +4
-0@@ -30,3 +30,7 @@ CFLAGS += -fno-asynchronous-unwind-tables ifneq ($(call cc-option,$(CC),-fvisibility=hidden,n),n) CFLAGS += -DGCC_HAS_VISIBILITY_ATTRIBUTE endif + +# Xen doesn't ever pass SSE arguments. Discard the SSE setup +# (i.e. `xor %eax, %eax`) before varadic function calls if possible. +$(call cc-option-add,CFLAGS,CC,-mskip-rax-setup)
Considering the gcc documentation for the option, I think this wants to sit right next to -mno-sse. Also I think it is "variadic" (and then in the description as well). With that
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 11 lines · Jan Beulich
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 08.01.18 at 11:46, <[email protected]> wrote:
This option is available from GCC 5 onwards, and was specifically introduced as an optimisation for Linux. When using varadic functions, the caller needs
to know how many floating point arguments were passed. Xen, like Linux, doesn't uses floating point arguments, so doesn't need to emit code to inform
varadic functions such asprintk()that there are zero arguments.The net delta for a release build is:
Quoted 8 lines
Quoted 5 lines
add/remove: 0/0 grow/shrink: 35/625 up/down: 603/-5489 (-4886)
with the single biggest change being:
x86_emulate101933 101751 -182What variadic function(s) are being used there? I can spot a couple of calls to
printk()and one call tocpu_has_amd_erratum(), but that can hardly account to 182 saved bytes.
I wondered the same, until I remembered mkec(), which is behind every generate_exception().
FWIW, I wasn't terribly happy with the way that one came out.
Quoted 14 lines
xen/arch/x86/Rules.mk CFLAGS += -fno-asynchronous-unwind-tables · line 36
Quoted 11 lines
xen/arch/x86/Rules.mk +4
-0@@ -30,3 +30,7 @@ CFLAGS += -fno-asynchronous-unwind-tables ifneq ($(call cc-option,$(CC),-fvisibility=hidden,n),n) CFLAGS += -DGCC_HAS_VISIBILITY_ATTRIBUTE endif + +# Xen doesn't ever pass SSE arguments. Discard the SSE setup +# (i.e. `xor %eax, %eax`) before varadic function calls if possible. +$(call cc-option-add,CFLAGS,CC,-mskip-rax-setup)Considering the gcc documentation for the option, I think this wants to sit right next to -mno-sse. Also I think it is "variadic" (and then in the description as well). With that
Quoted 1 line
Reviewed-by Jan Beulich <[email protected]>
I'll see what I can do.
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 17 lines
Quoted 1 line
Quoted 1 line · On 08.01.18 at 13:10, <[email protected]> wrote:
Quoted 15 lines · Jan Beulich
Quoted 15 lines
Quoted 1 line
Quoted 1 line · On 08.01.18 at 11:46, <[email protected]> wrote:
This option is available from GCC 5 onwards, and was specifically introduced as an optimisation for Linux. When using varadic functions, the caller needs
to know how many floating point arguments were passed. Xen, like Linux, doesn't uses floating point arguments, so doesn't need to emit code to inform
varadic functions such asprintk()that there are zero arguments.The net delta for a release build is:
add/remove: 0/0 grow/shrink: 35/625 up/down: 603/-5489 (-4886)
with the single biggest change being:
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
x86_emulate101933 101751 -182What variadic function(s) are being used there? I can spot a couple of calls to
printk()and one call tocpu_has_amd_erratum(), but that can hardly account to 182 saved bytes.I wondered the same, until I remembered
mkec(), which is behind everygenerate_exception().
But that's an inline function, which the compiler should be able to avoid setting %eax without further help.
Quoted 15 lines
Quoted 13 lines
xen/arch/x86/Rules.mk CFLAGS += -fno-asynchronous-unwind-tables · line 36
Quoted 10 lines
xen/arch/x86/Rules.mk +4
-0@@ -30,3 +30,7 @@ CFLAGS += -fno-asynchronous-unwind-tables ifneq ($(call cc-option,$(CC),-fvisibility=hidden,n),n) CFLAGS += -DGCC_HAS_VISIBILITY_ATTRIBUTE endif + +# Xen doesn't ever pass SSE arguments. Discard the SSE setup +# (i.e. `xor %eax, %eax`) before varadic function calls if possible. +$(call cc-option-add,CFLAGS,CC,-mskip-rax-setup)Considering the gcc documentation for the option, I think this wants to sit right next to -mno-sse. Also I think it is "variadic" (and then in the description as well). With that
Quoted 1 line
Reviewed-by Jan Beulich <[email protected]>
Quoted 1 line
I'll see what I can do.
Thanks. One more thing though: The description could also do with some editing - it is not the fact that we never _pass_ any values in XMM registers, but the fact that as of commit d80c482605 ("x86-64:
globally use -mno-sse") variadic functions have XMM-register-related prologues generated which makes this change safe. Otherwise the warning in the documentation would very much apply. Also s/caller/callee/ in the second line.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel