[clang] [Clang] Re-write codegen for atomic_test_and_set and atomic_clear (PR #120449)

James Y Knight via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 19 19:05:59 PST 2024


jyknight wrote:

Yes, the code in libpcap is correct, and the new Clang behavior is incorrect.

`__atomic_clear` and `__atomic_test_and_set` are intentionally different from the other atomic builtins, in that they are _not_ type-generic, but instead always operate on the single byte at the provided address. Thus, the pointee-type is irrelevant. (And yes, both operations should behave the same; they are a pair. GCC's docs for `__atomic_clear` are wrong; both are actually implemented by GCC and previous-Clang as accepting `void*`.)

https://github.com/llvm/llvm-project/pull/120449


More information about the cfe-commits mailing list