[llvm-dev] Over-ride the compiler built-in functions .

Umesh Kalappa via llvm-dev llvm-dev at lists.llvm.org
Mon Jan 20 02:57:05 PST 2020

Hi All,

We are trying to override the compiler atomic builtin functions like

int  __sync_val_compare_and_swap( int *p,int x ,int y)
         return *p; //ignore the function semantics here

int main()
         int x = 0, y = 1;
   y = __sync_val_compare_and_swap(&x, x, y);

   return x + y;

clang throws the error like

test.c:1:6: error: cannot redeclare builtin function
int  __sync_val_compare_and_swap( int *p,int x ,int y)
test.c:1:6: note: '__sync_val_compare_and_swap' is a builtin with type
'void ()'
test.c:1:6: error: definition of builtin function
int  __sync_val_compare_and_swap( int *p,int x ,int y)

But GCC compiles it and we think that GCC is right here unlike clang.

We would like to hear from the community view on this.

Thank you
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200120/bc5eb5a9/attachment.html>

More information about the llvm-dev mailing list