[libcxx-commits] [libcxx] 86478c7 - [libcxx][atomic] Remove workaround for PR31864
Kai Luo via libcxx-commits
libcxx-commits at lists.llvm.org
Sat Mar 5 16:56:36 PST 2022
Author: Kai Luo
Date: 2022-03-06T00:56:32Z
New Revision: 86478c7ad8a7a5fd844429a27cda896774619975
URL: https://github.com/llvm/llvm-project/commit/86478c7ad8a7a5fd844429a27cda896774619975
DIFF: https://github.com/llvm/llvm-project/commit/86478c7ad8a7a5fd844429a27cda896774619975.diff
LOG: [libcxx][atomic] Remove workaround for PR31864
I believe the origin issue in PR31864 has been addressed by https://reviews.llvm.org/D59566.
As discussed in https://github.com/llvm/llvm-project/issues/53840, `ATOMIC_LLONG_LOCK_FREE == 2` sometimes is not consistent with `std::atomic<long long>::is_always_lock_free`, since the macro takes `long long`'s ABI alignment into account. https://reviews.llvm.org/D28213 proposed we should not rely on ABI alignment of types, thus we have consistent `ATOMIC_LLONG_LOCK_FREE` and `std::atomic<long long>::is_always_lock_free` on x86's old cpu. Currently, I plan to move on to remove the workaround which should have been addressed and don't want to break current tests.
Reviewed By: #libc, ldionne, Quuxplusone
Differential Revision: https://reviews.llvm.org/D119931
Added:
Modified:
libcxx/test/std/atomics/atomics.lockfree/isalwayslockfree.pass.cpp
Removed:
################################################################################
diff --git a/libcxx/test/std/atomics/atomics.lockfree/isalwayslockfree.pass.cpp b/libcxx/test/std/atomics/atomics.lockfree/isalwayslockfree.pass.cpp
index 477208ad18c5c..2d72b9169f940 100644
--- a/libcxx/test/std/atomics/atomics.lockfree/isalwayslockfree.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.lockfree/isalwayslockfree.pass.cpp
@@ -29,40 +29,6 @@ template <typename T> void checkAlwaysLockFree() {
assert(std::atomic<T>().is_lock_free());
}
-// FIXME: This separate test is needed to work around llvm.org/PR31864
-// which causes ATOMIC_LLONG_LOCK_FREE to be defined as '1' in 32-bit builds
-// even though __atomic_always_lock_free returns true for the same type.
-constexpr bool NeedWorkaroundForPR31864 =
-#if defined(__clang__)
-(sizeof(void*) == 4); // Needed on 32 bit builds
-#else
-false;
-#endif
-
-template <bool Disable = NeedWorkaroundForPR31864,
- std::enable_if_t<!Disable>* = nullptr,
- class LLong = long long,
- class ULLong = unsigned long long>
-void checkLongLongTypes() {
- static_assert(std::atomic<LLong>::is_always_lock_free == (2 == ATOMIC_LLONG_LOCK_FREE), "");
- static_assert(std::atomic<ULLong>::is_always_lock_free == (2 == ATOMIC_LLONG_LOCK_FREE), "");
-}
-
-// Used to make the calls to __atomic_always_lock_free dependent on a template
-// parameter.
-template <class T> constexpr size_t getSizeOf() { return sizeof(T); }
-
-template <bool Enable = NeedWorkaroundForPR31864,
- std::enable_if_t<Enable>* = nullptr,
- class LLong = long long,
- class ULLong = unsigned long long>
-void checkLongLongTypes() {
- constexpr bool ExpectLockFree = __atomic_always_lock_free(getSizeOf<LLong>(), 0);
- static_assert(std::atomic<LLong>::is_always_lock_free == ExpectLockFree, "");
- static_assert(std::atomic<ULLong>::is_always_lock_free == ExpectLockFree, "");
- static_assert((0 != ATOMIC_LLONG_LOCK_FREE) == ExpectLockFree, "");
-}
-
void run()
{
// structs and unions can't be defined in the template invocation.
@@ -140,7 +106,8 @@ void run()
static_assert(std::atomic<unsigned int>::is_always_lock_free == (2 == ATOMIC_INT_LOCK_FREE), "");
static_assert(std::atomic<long>::is_always_lock_free == (2 == ATOMIC_LONG_LOCK_FREE), "");
static_assert(std::atomic<unsigned long>::is_always_lock_free == (2 == ATOMIC_LONG_LOCK_FREE), "");
- checkLongLongTypes();
+ static_assert(std::atomic<long long>::is_always_lock_free == (2 == ATOMIC_LLONG_LOCK_FREE), "");
+ static_assert(std::atomic<unsigned long long>::is_always_lock_free == (2 == ATOMIC_LLONG_LOCK_FREE), "");
static_assert(std::atomic<void*>::is_always_lock_free == (2 == ATOMIC_POINTER_LOCK_FREE), "");
static_assert(std::atomic<std::nullptr_t>::is_always_lock_free == (2 == ATOMIC_POINTER_LOCK_FREE), "");
More information about the libcxx-commits
mailing list