From patchwork Wed Oct 21 15:17:03 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 9292 Received: (qmail 69602 invoked by alias); 21 Oct 2015 15:17:11 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 69581 invoked by uid 89); 21 Oct 2015 15:17:10 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.5 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-ob0-f182.google.com MIME-Version: 1.0 X-Received: by 10.60.165.72 with SMTP id yw8mr6496231oeb.45.1445440623927; Wed, 21 Oct 2015 08:17:03 -0700 (PDT) In-Reply-To: References: <20151012232028.GC8797@intel.com> Date: Wed, 21 Oct 2015 08:17:03 -0700 Message-ID: Subject: Re: [PATCH 5/6] Optimize i386 syscall inlining From: "H.J. Lu" To: Andreas Schwab Cc: GNU C Library On Wed, Oct 21, 2015 at 8:01 AM, Andreas Schwab wrote: > "H.J. Lu" writes: > >> Which GCC are you using? > > https://build.opensuse.org/package/show/openSUSE:Factory/gcc5 > > Andreas. I am testing this patch and will check it in if it passes check. diff --git a/sysdeps/unix/sysv/linux/i386/sysdep.h b/sysdeps/unix/sysv/linux/i386/sysdep.h index 76db7b8..5830544 100644 --- a/sysdeps/unix/sysv/linux/i386/sysdep.h +++ b/sysdeps/unix/sysv/linux/i386/sysdep.h @@ -229,9 +229,15 @@ extern int __syscall_error (int) /* Since GCC 5 and above can properly spill %ebx with PIC when needed, we can inline syscalls with 6 arguments if GCC 5 or above is used - to compile glibc. */ + to compile glibc. Disable GCC 5 optimization when compiling for + profiling since asm ("ebp") can't be used to put the 6th argument + in %ebp for syscall. */ -#if !__GNUC_PREREQ (5,0) +#if __GNUC_PREREQ (5,0) && !defined PROF +# define OPTIMIZE_FOR_GCC_5 +#endif + +#ifndef OPTIMIZE_FOR_GCC_5 /* We need some help from the assembler to generate optimal code. We define some macros here which later will be used. */ asm (".L__X'%ebx = 1\n\t" @@ -328,7 +334,7 @@ struct libc_do_syscall_args INTERNAL_SYSCALL_MAIN_INLINE(name, err, 5, args) /* Each object using 6-argument inline syscalls must include a definition of __libc_do_syscall. */ -#if __GNUC_PREREQ (5,0) +#ifdef OPTIMIZE_FOR_GCC_5 # define INTERNAL_SYSCALL_MAIN_6(name, err, args...) \ INTERNAL_SYSCALL_MAIN_INLINE(name, err, 6, args) #else /* GCC 5 */ @@ -353,7 +359,7 @@ struct libc_do_syscall_args INTERNAL_SYSCALL_MAIN_##nr (name, err, args); \ (int) resultvar; }) #ifdef I386_USE_SYSENTER -# if __GNUC_PREREQ (5,0) +# ifdef OPTIMIZE_FOR_GCC_5 # ifdef SHARED # define INTERNAL_SYSCALL_MAIN_INLINE(name, err, nr, args...) \ LOADREGS_##nr(args) \ @@ -437,7 +443,7 @@ struct libc_do_syscall_args # endif # endif /* GCC 5 */ #else -# if __GNUC_PREREQ (5,0) +# ifdef OPTIMIZE_FOR_GCC_5 # define INTERNAL_SYSCALL_MAIN_INLINE(name, err, nr, args...) \ LOADREGS_##nr(args) \ asm volatile ( \ @@ -539,7 +545,7 @@ struct libc_do_syscall_args # define RESTOREARGS_5 #endif -#if __GNUC_PREREQ (5,0) +#ifdef OPTIMIZE_FOR_GCC_5 # define LOADREGS_0() # define ASMARGS_0() # define LOADREGS_1(arg1) \ @@ -606,7 +612,7 @@ struct libc_do_syscall_args #endif /* Consistency check for position-independent code. */ -#if defined __PIC__ && !__GNUC_PREREQ (5,0) +#if defined __PIC__ && !defined OPTIMIZE_FOR_GCC_5 # define check_consistency() \ ({ int __res; \ __asm__ __volatile__