[v2,4/5] x86_64: Define __ASSUME_SYSCALL_NAMED_WORKS for Linux

Message ID 20230325140815.4170296-5-xry111@xry111.site
State Dropped
Series linux: Avoid va_list for generic syscall wrappers if possible |


Context Check Description
dj/TryBot-apply_patch success Patch applied to master at the time it was sent

Commit Message

Xi Ruoyao March 25, 2023, 2:08 p.m. UTC
  x86_64 calling convention treats the variable arguments same as named
ones (it sets %al to the number of floating-point variable arguments but
it's simply ignored because our syscall wrappers don't take
floating-point arguments), and when each argument is an integer
not wider than 8 bytes, the ith argument is in registers %rdi, %rsi,
%rdx, %rcx, %r8, and %r9 (0 <= i < 6), or the stack slot at
(%rsp + 8 * (i - 6)) (i >= 8) no matter how many arguments are passed.
So we can define __ASSUME_SYSCALL_NAMED_WORKS to avoid unnecessary stack
stores in the syscall wrappers caused by va_start.
 sysdeps/unix/sysv/linux/x86_64/kernel-features.h | 9 +++++++++
 1 file changed, 9 insertions(+)


diff --git a/sysdeps/unix/sysv/linux/x86_64/kernel-features.h b/sysdeps/unix/sysv/linux/x86_64/kernel-features.h
index 68322ff476..7783a0eebc 100644
--- a/sysdeps/unix/sysv/linux/x86_64/kernel-features.h
+++ b/sysdeps/unix/sysv/linux/x86_64/kernel-features.h
@@ -23,4 +23,13 @@ 
 # define __ASSUME_WORDSIZE64_ILP32	1
+/* Define this if the calling convention for passing x named arguments and y
+   variable arguments is same as passing (x + y) named arguments, while each
+   argument is either an integer of which the width is less than or equal to
+   "long", or a pointer; and an argument can be fetched from the same register
+   or the same offset from the stack pointer no matter how many (maybe zero)
+   arguments are passed after it.  It avoids useless stack stores caused by
+   usage of va_start.  */
 #include_next <kernel-features.h>