Opened 7 years ago
Closed 6 years ago
#56 closed defect (fixed)
Overloading for GCC atomic builtins is broken
Reported by: | Thierry Delisle | Owned by: | |
---|---|---|---|
Priority: | major | Component: | cfa-cc |
Version: | 1.0 | Keywords: | |
Cc: |
Description
In gcc .def files, gcc atomic builtins are defined like so:
void __sync_fetch_and_add(); char __sync_fetch_and_add_1(volatile void *, char); short __sync_fetch_and_add_2(volatile void *, short); int __sync_fetch_and_add_4(volatile void *, int); long long int __sync_fetch_and_add_8(volatile void *, long long int); __int128 __sync_fetch_and_add_16(volatile void *, __int128);
However, the documentation declares builtins as :
type __sync_fetch_and_add (type *ptr, type value, ...)
The problem is 2-fold, Cforall does not support the third parameter and requires using the routine with the _N.
This problem is present for most/all atomic builtins.
I am not convinced that simply renaming the overloads to remove the suffix will work because these functions are not name-mangled since they are builtins and generating the wrappers would be tricky.
Also, with don't want to separately compile the wrapper because these are performance sensitive functions.
Another problem is that the type of the third parameter is not specified.
Finally, suspect that extraneous casting in the generated code for these functions could cause significant problems.
I am not sure what the best approach is but maybe we need to consider reading .def files in without trying to generate c code for them.
Fixed by hand