ACLE and UBSan disagree about clz with input zero
D152023 made calls to __builtin_clz and __builtin_ctz with input 0 to be undefined behaviour (RFC here). However we use them in the arm-acle.h to implement __clz:
https://github.com/llvm/llvm-project/blob/c91246b71eec9fc1d4454ddcdc574733a699e190/clang/lib/Headers/arm_acle.h#L143
The ACLE documentation for __clz states:
When x is zero it returns the argument width, i.e. 32 or 64.
The definitions in the header will need to be updated to handle the zero case.
@llvm/issue-subscribers-backend-aarch64
@llvm/issue-subscribers-backend-arm
I broke this so I'll fix it.
Its look gcc might have the same bug https://godbolt.org/z/YxKab9cMG ? The code appears to instrumented with a zero check.