[llvmlinux] [PATCH] x86/hweight: LLVMLinux: Fix __arch_hweight{32, 64}() for compilation with clang

Jan-Simon Moeller dl9pf at gmx.de
Sun Sep 13 21:45:27 UTC 2015

Am Sonntag, 13. September 2015, 23:14:22 schrieb PaX Team:

> > does not specify that the "call __sw_hweight64" instruction may 
> > caller saved registers (like %rcx and %rdx).
> actually, the __sw_hweight* functions may *not* clobber anything. the
> trick is in how lib/hweight.o is compiled: CFLAGS contains a set of
> -fcall-saved-REG switches (cf. ARCH_HWEIGHT_CFLAGS) that effectively
> override the function call ABI for the functions defined in this file
> so there's no need for the callers to specify any extra clobbers. this
> way the fast path execution (inlined popcnt insn) doesn't unnecessarily
> perturb the register allocator in the callers.

The issues is that clang does not support these flags. So exactly the
"do not clobber" trick does not happen. 


More information about the LLVMLinux mailing list