From 5a10fe05cb0b8169b7616f79471e50751f3222f5 Mon Sep 17 00:00:00 2001 From: Sedat Dilek Date: Mon, 12 Oct 2015 09:39:28 +0200 Subject: [PATCH] x86/hweight: boot: llvmlinux: Workaround LLVM Bug PR9457 This workaround is required to boot my Ubuntu/precise AMD64 system when building with '-no-integrated-as' compiler-flag. For more details see [1]. See also [2], when IA is used. Tested with Clang v3.7 and v3.8 against Linux v4.3.y and v4.4.y kernels. [1] https://llvm.org/bugs/show_bug.cgi?id=9457 [2] https://llvm.org/bugs/show_bug.cgi?id=24487 --- arch/x86/Kconfig | 4 ++-- arch/x86/include/asm/arch_hweight.h | 18 ++++-------------- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index db3622f22b61..9c79418cb783 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -280,8 +280,8 @@ config X86_32_LAZY_GS config ARCH_HWEIGHT_CFLAGS string - default "-fcall-saved-ecx -fcall-saved-edx" if X86_32 - default "-fcall-saved-rdi -fcall-saved-rsi -fcall-saved-rdx -fcall-saved-rcx -fcall-saved-r8 -fcall-saved-r9 -fcall-saved-r10 -fcall-saved-r11" if X86_64 + # Workaround LLVM Bug PR9457 + default "" if (X86_32 || X86_64) config ARCH_SUPPORTS_UPROBES def_bool y diff --git a/arch/x86/include/asm/arch_hweight.h b/arch/x86/include/asm/arch_hweight.h index 259a7c1ef709..33f828a659bc 100644 --- a/arch/x86/include/asm/arch_hweight.h +++ b/arch/x86/include/asm/arch_hweight.h @@ -23,13 +23,8 @@ */ static __always_inline unsigned int __arch_hweight32(unsigned int w) { - unsigned int res = 0; - - asm (ALTERNATIVE("call __sw_hweight32", POPCNT32, X86_FEATURE_POPCNT) - : "="REG_OUT (res) - : REG_IN (w)); - - return res; +/* Workaround LLVM Bug PR9457 */ + return __sw_hweight32(w); } static inline unsigned int __arch_hweight16(unsigned int w) @@ -51,13 +46,8 @@ static inline unsigned long __arch_hweight64(__u64 w) #else static __always_inline unsigned long __arch_hweight64(__u64 w) { - unsigned long res = 0; - - asm (ALTERNATIVE("call __sw_hweight64", POPCNT64, X86_FEATURE_POPCNT) - : "="REG_OUT (res) - : REG_IN (w)); - - return res; +/* Workaround LLVM Bug PR9457 */ + return __sw_hweight64(w); } #endif /* CONFIG_X86_32 */ -- 2.9.0