Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[libc++] Increase atomic_ref's required alignment for small types (ll…
…vm#99654) This patch increases the alignment requirement for std::atomic_ref such that we can guarantee lockfree operations more often. Specifically, we require types that are 1, 2, 4, 8, or 16 bytes in size to be aligned to at least their size to be used with std::atomic_ref. This is the case for most types, however a notable exception is `long long` on x86, which is 8 bytes in length but has an alignment of 4. As a result of this patch, one has to be more careful about the alignment of objects used with std::atomic_ref. Failure to provide a properly-aligned object to std::atomic_ref is a precondition violation and is technically UB. On the flipside, this allows us to provide an atomic_ref that is actually lockfree more often, which is an important QOI property. More information in the discussion at llvm#99570 (comment). Co-authored-by: Louis Dionne <ldionne.2@gmail.com>
- Loading branch information