| Issue |
179061
|
| Summary |
Incorrect prototype in __clzsi2, __clzdi2, and some others
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
vit9696
|
LLVM implementation apparently uses signed integers for bit count functions in compiler-rt:
All of these have a signed integer argument (si_int, di_int, ti_int):
```c
COMPILER_RT_ABI int __clzsi2(si_int a);
COMPILER_RT_ABI int __clzdi2(di_int a);
COMPILER_RT_ABI int __clzti2(ti_int a);
COMPILER_RT_ABI int __ctzsi2(si_int a);
COMPILER_RT_ABI int __ctzdi2(di_int a);
COMPILER_RT_ABI int __ctzti2(ti_int a);
COMPILER_RT_ABI int __ffssi2(si_int a);
COMPILER_RT_ABI int __ffsdi2(di_int a);
COMPILER_RT_ABI int __ffsti2(ti_int a);
COMPILER_RT_ABI int __paritysi2(si_int a);
COMPILER_RT_ABI int __paritydi2(di_int a);
COMPILER_RT_ABI int __parityti2(ti_int a);
```
This contradicts the runtime library reference published by gcc:
```c
int __clzsi2 (unsigned int a);
int __clzdi2 (unsigned long a);
int __clzti2 (unsigned long long a);
int __ctzsi2 (unsigned int a);
int __ctzdi2 (unsigned long a);
int __ctzti2 (unsigned long long a);
int __ffsdi2 (unsigned long a);
int __ffsti2 (unsigned long long a);
int __paritysi2 (unsigned int a);
int __paritydi2 (unsigned long a);
int __parityti2 (unsigned long long a);
int __popcountsi2 (unsigned int a);
int __popcountdi2 (unsigned long a);
int __popcountti2 (unsigned long long a);
```
And honestly makes little sense for these functions.
I understand that the code will likely work regardless of the prototype due to immediate cast right after the beginning of the function, but it still looks weird. Is this code trying to workaround some kind of bug or is it merely an overlook which is better to fix?
GCC runtime library reference:
https://gcc.gnu.org/onlinedocs/gccint/Integer-library-routines.html#Bit-operations
Function reference:
https://github.com/llvm/llvm-project/blob/main/compiler-rt/lib/builtins/clzsi2.c
https://github.com/llvm/llvm-project/blob/main/compiler-rt/lib/builtins/clzdi2.c
https://github.com/llvm/llvm-project/blob/main/compiler-rt/lib/builtins/clzti2.c
Type definition:
https://github.com/llvm/llvm-project/blob/main/compiler-rt/lib/builtins/int_types.h
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs