Workaround for LLVM bug 11663. Prevent endless recursion in
c?zdi2(), where calls to builtin_c?z() are expanded to
c?zdi2() instead of c?zsi2().
Instead of placing this workaround in c?zdi2.c, put it in this global
header to prevent other C files from making the detour through
__c?zdi2() as well.
This problem has been observed on FreeBSD for sparc64 and mips64 with
GCC 4.2.1, and for riscv with GCC 5.2.0. Presumably it's any version of
GCC, and targeting an arch that does not have dedicated bit counting
instructions.
PR: https://bugs.llvm.org/show_bug.cgi?id=11663
This problem was brought to my attention by Adrian Glaubitz yesterday at
FOSDEM. He asked me if I could help him get this upstream. The workaround is
already present in Rust's version of compiler-rt, but obviously they'd like to have
this upstream: https://github.com/rust-lang/compiler-rt/pull/35/files