From 6598af4a54b0f67cdaf14ca1b6809e6f109679e8 Mon Sep 17 00:00:00 2001 From: Siva Chandra Reddy Date: Thu, 2 Jan 2020 11:09:18 -0800 Subject: [PATCH] [libc] Add __attribute__((always_inline)) to x86_64 syscall functions. Summary: Some syscalls like SYS_clone do not tolerate a return instruction after the syscall instruction. Marking the syscall functions with the `always_inline` attribute accommodates such syscalls as inlining eliminates the return instruction. Reviewers: abrachet, phosek Subscribers: MaskRay, tschuett, libc-commits Tags: #libc-project Differential Revision: https://reviews.llvm.org/D72102 --- libc/config/linux/x86_64/syscall.h.inc | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/libc/config/linux/x86_64/syscall.h.inc b/libc/config/linux/x86_64/syscall.h.inc index 944ac99..33f211c 100644 --- a/libc/config/linux/x86_64/syscall.h.inc +++ b/libc/config/linux/x86_64/syscall.h.inc @@ -1,4 +1,4 @@ -//===------------ inline implementation of x86_64 syscalls --------------*-===// +//===------------ inline implementation of x86_64 syscalls ----------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -14,7 +14,7 @@ namespace __llvm_libc { -inline long syscall(long __number) { +__attribute__((always_inline)) inline long syscall(long __number) { long retcode; LIBC_INLINE_ASM("syscall" : "=a"(retcode) : @@ -23,7 +23,7 @@ inline long syscall(long __number) { return retcode; } -inline long syscall(long __number, long __arg1) { +__attribute__((always_inline)) inline long syscall(long __number, long __arg1) { long retcode; LIBC_INLINE_ASM("syscall" : "=a"(retcode) : @@ -32,7 +32,8 @@ inline long syscall(long __number, long __arg1) { return retcode; } -inline long syscall(long __number, long __arg1, long __arg2) { +__attribute__((always_inline)) inline long syscall( + long __number, long __arg1, long __arg2) { long retcode; LIBC_INLINE_ASM("syscall" : "=a"(retcode) : @@ -41,7 +42,8 @@ inline long syscall(long __number, long __arg1, long __arg2) { return retcode; } -inline long syscall(long __number, long __arg1, long __arg2, long __arg3) { +__attribute__((always_inline)) inline long syscall( + long __number, long __arg1, long __arg2, long __arg3) { long retcode; LIBC_INLINE_ASM("syscall" : "=a"(retcode) : @@ -50,7 +52,7 @@ inline long syscall(long __number, long __arg1, long __arg2, long __arg3) { return retcode; } -inline long syscall( +__attribute__((always_inline)) inline long syscall( long __number, long __arg1, long __arg2, long __arg3, long __arg4) { long retcode; register long r10 __asm__("r10") = __arg4; @@ -61,8 +63,9 @@ inline long syscall( return retcode; } -inline long syscall(long __number, long __arg1, long __arg2, long __arg3, - long __arg4, long __arg5) { +__attribute__((always_inline)) inline long syscall( + long __number, long __arg1, long __arg2, long __arg3, long __arg4, + long __arg5) { long retcode; register long r10 __asm__("r10") = __arg4; register long r8 __asm__("r8") = __arg5; @@ -74,8 +77,9 @@ inline long syscall(long __number, long __arg1, long __arg2, long __arg3, return retcode; } -inline long syscall(long __number, long __arg1, long __arg2, long __arg3, - long __arg4, long __arg5, long __arg6) { +__attribute__((always_inline)) inline long syscall( + long __number, long __arg1, long __arg2, long __arg3, long __arg4, + long __arg5, long __arg6) { long retcode; register long r10 __asm__("r10") = __arg4; register long r8 __asm__("r8") = __arg5; -- 2.7.4