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

PaX Team pageexec at gmail.com
Sun Sep 13 22:12:09 UTC 2015

On 13 Sep 2015 at 23:45, Jan-Simon Moeller wrote:

> Am Sonntag, 13. September 2015, 23:14:22 schrieb PaX Team:
> > > does not specify that the "call __sw_hweight64" instruction may 
> clobber
> > > 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. 

i know, that's why my patch removed the fast path which works with clang
(but it isn't good for upstream, hence my suggestion to use thunk*.S

More information about the LLVMLinux mailing list