Hi,
Currently atomic intrinsics are overloaded by the datatype. That allow us to use a non-suffixed version for any data-type, like this:
signed char sc;
void foo(void) {
(void) __sync_fetch_and_add(&sc, 1);
}
instead of explicitly specifying data-type, as here:
signed char sc;
void foo(void) {
(void) __sync_fetch_and_add_1(&sc, 1);
}
For both of these examples clang generates
%0 = atomicrmw add i8* @sc, i8 1 seq_cst
However, it looks like due to this overloading, we completely ignore the size suffix. For instance, for
signed char sc;
void foo(void) {
(void) __sync_fetch_and_add_4(&sc, 1);
}
clang will generate the same IR with i8:
%0 = atomicrmw add i8* @sc, i8 1 seq_cst ; << i8, instead of i32
Is it an expected behavior, or a bug?
Thanks,
Michael