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

PaX Team pageexec at gmail.com
Sun Sep 13 23:10:58 UTC 2015

On 13 Sep 2015 at 15:46, Sanjoy Das wrote:

> LLVM already has a "preserve_allcc" that constrains the callee to not
> clobber any registers other than the return value register and %r11.

in that case an alternative would be to use this calling convention
and declare %r11 clobbered on the linux side. it may not even have to
be conditional on clang as i doubt that a single register matters much
for actual callers (but someone will have to compare the generated asm
to be sure ;).

> As an alternative to thunk'ifying the helper routines, you could also
> discuss with clang developers if adding a second "preserves_all"
> calling convention to LLVM that also preserves %r11 and making it
> usable from the clang frontend is reasonable.  If there are many
> places in the kernel that require -fcall-saved-REG, then a new calling
> convention in clang may make things more scalable.

it's only used at this one place, a few others use the explicit thunks.
this is why i said that converting the popcnt wrappers to that facility
might be an upstreamable alternative as well.

More information about the LLVMLinux mailing list