Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1602039

Re: [PATCH 2/2] x86, boot: Use regparm=0 for memcpy and memset when using clang

From Ingo Molnar <mingo@kernel.org>
Newsgroups linux.kernel
Subject Re: [PATCH 2/2] x86, boot: Use regparm=0 for memcpy and memset when using clang
Date 2017-03-16 08:50 +0100
Message-ID <tlykx-3qz-11@gated-at.bofh.it> (permalink)
References <tloXT-59Y-9@gated-at.bofh.it> <tloXT-59Y-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


* Michael Davidson <md@google.com> wrote:

> Use the standard regparm=0 calling convention for memcpy and
> memset when building with clang.
> 
> This is a work around for a long standing clang bug
> (see https://llvm.org/bugs/show_bug.cgi?id=3997) where
> clang always uses the standard regparm=0 calling convention
> for any implcit calls to memcpy and memset that it generates
> (eg for structure assignments and initialization) even if an
> alternate calling convention such as regparm=3 has been specified.
> 
> Signed-off-by: Michael Davidson <md@google.com>
> ---
>  arch/x86/boot/copy.S   | 15 +++++++++++++--
>  arch/x86/boot/string.h | 13 +++++++++++++
>  2 files changed, 26 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/x86/boot/copy.S b/arch/x86/boot/copy.S
> index 1eb7d298b47d..57142d1ad0d2 100644
> --- a/arch/x86/boot/copy.S
> +++ b/arch/x86/boot/copy.S
> @@ -18,6 +18,12 @@
>  	.text
>  
>  GLOBAL(memcpy)
> +#ifdef	__clang__	/* Use normal ABI calling conventions */
> +	movw	4(%esp), %ax
> +	movw	8(%esp), %dx
> +	movw	12(%esp), %cx
> +#endif
> +_memcpy:
>  	pushw	%si
>  	pushw	%di
>  	movw	%ax, %di
> @@ -34,6 +40,11 @@ GLOBAL(memcpy)
>  ENDPROC(memcpy)
>  
>  GLOBAL(memset)
> +#ifdef	__clang__	/* Use normal ABI calling conventions */
> +	movw	4(%esp), %ax
> +	movw	8(%esp), %dx
> +	movw	12(%esp), %cx
> +#endif

I don't think we want to add such ugly workarounds for clang bugs in a piecemail 
wise manner. If this was the _only_ workaround required to have a working kernel 
built with clang then maybe, but there's no way to tell from this submission.

Thanks,

	Ingo

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 2/2] x86, boot: Use regparm=0 for memcpy and memset when using clang Michael Davidson <md@google.com> - 2017-03-15 22:50 +0100
  Re: [PATCH 2/2] x86, boot: Use regparm=0 for memcpy and memset when  using clang Ingo Molnar <mingo@kernel.org> - 2017-03-16 08:50 +0100
    Re: [PATCH 2/2] x86, boot: Use regparm=0 for memcpy and memset when  using clang Michael Davidson <md@google.com> - 2017-03-16 16:30 +0100

csiph-web