Skip to content

[libc++] Simplify features for detecting atomics' support. #75553

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libcxx/test/libcxx/atomics/atomics.align/align.pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
//
// UNSUPPORTED: c++03
// REQUIRES: is-lockfree-runtime-function
// REQUIRES: has-128-bit-atomics
// ADDITIONAL_COMPILE_FLAGS: -Wno-psabi
// ... since C++20 std::__atomic_base initializes, so we get a warning about an
// ABI change for vector variants since the constructor code for that is
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// XFAIL: !has-64-bit-atomics
// UNSUPPORTED: !non-lockfree-atomics

// static constexpr bool is_always_lock_free = implementation-defined;
// bool is_lock_free() const volatile noexcept;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// XFAIL: !has-64-bit-atomics
// UNSUPPORTED: !non-lockfree-atomics

// floating-point-type operator=(floating-point-type) volatile noexcept;
// floating-point-type operator=(floating-point-type) noexcept;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// XFAIL: !has-64-bit-atomics
// UNSUPPORTED: !non-lockfree-atomics

// bool compare_exchange_strong(T& expected, T desired,
// memory_order success, memory_order failure) volatile noexcept;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// XFAIL: !has-64-bit-atomics
// UNSUPPORTED: !non-lockfree-atomics

// bool compare_exchange_weak(T& expected, T desired,
// memory_order success, memory_order failure) volatile noexcept;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// XFAIL: !has-64-bit-atomics
// UNSUPPORTED: !non-lockfree-atomics

// constexpr atomic() noexcept;
// constexpr atomic(floating-point-type) noexcept;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// XFAIL: !has-64-bit-atomics
// UNSUPPORTED: !non-lockfree-atomics

// T exchange(T, memory_order = memory_order::seq_cst) volatile noexcept;
// T exchange(T, memory_order = memory_order::seq_cst) noexcept;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// UNSUPPORTED: c++03, c++11, c++14, c++17
// UNSUPPORTED: LIBCXX-AIX-FIXME
// XFAIL: !has-64-bit-atomics
// UNSUPPORTED: !non-lockfree-atomics

// https://github.com/llvm/llvm-project/issues/72893
// XFAIL: target={{x86_64-.*}} && tsan
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// UNSUPPORTED: c++03, c++11, c++14, c++17
// UNSUPPORTED: LIBCXX-AIX-FIXME
// XFAIL: !has-64-bit-atomics
// UNSUPPORTED: !non-lockfree-atomics

// https://github.com/llvm/llvm-project/issues/72893
// XFAIL: target={{x86_64-.*}} && tsan
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// XFAIL: !has-64-bit-atomics
// UNSUPPORTED: !non-lockfree-atomics

// floating-point-type load(memory_order = memory_order::seq_cst) volatile noexcept;
// floating-point-type load(memory_order = memory_order::seq_cst) noexcept;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// XFAIL: !has-64-bit-atomics
// UNSUPPORTED: !non-lockfree-atomics

// static constexpr bool is_always_lock_free = implementation-defined;
// bool is_lock_free() const volatile noexcept;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
// XFAIL: availability-synchronization_library-missing
// UNSUPPORTED: c++03, c++11, c++14, c++17
// XFAIL: !has-64-bit-atomics
// UNSUPPORTED: !non-lockfree-atomics

// void notify_all() volatile noexcept;
// void notify_all() noexcept;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
// XFAIL: availability-synchronization_library-missing
// UNSUPPORTED: c++03, c++11, c++14, c++17
// XFAIL: !has-64-bit-atomics
// UNSUPPORTED: !non-lockfree-atomics

// void notify_one() volatile noexcept;
// void notify_one() noexcept;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// XFAIL: !has-64-bit-atomics
// UNSUPPORTED: !non-lockfree-atomics

// operator floating-point-type() volatile noexcept;
// operator floating-point-type() noexcept;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// UNSUPPORTED: c++03, c++11, c++14, c++17
// UNSUPPORTED: LIBCXX-AIX-FIXME
// XFAIL: !has-64-bit-atomics
// UNSUPPORTED: !non-lockfree-atomics

// floating-point-type operator-=(floating-point-type) volatile noexcept;
// floating-point-type operator-=(floating-point-type) noexcept;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// UNSUPPORTED: c++03, c++11, c++14, c++17
// UNSUPPORTED: LIBCXX-AIX-FIXME
// XFAIL: !has-64-bit-atomics
// UNSUPPORTED: !non-lockfree-atomics

// floating-point-type operator+=(floating-point-type) volatile noexcept;
// floating-point-type operator+=(floating-point-type) noexcept;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// XFAIL: !has-64-bit-atomics
// UNSUPPORTED: !non-lockfree-atomics

// void store(floating-point-type, memory_order = memory_order::seq_cst) volatile noexcept;
// void store(floating-point-type, memory_order = memory_order::seq_cst) noexcept;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// UNSUPPORTED: c++03, c++11, c++14, c++17
// XFAIL: availability-synchronization_library-missing
// XFAIL: !has-64-bit-atomics
// UNSUPPORTED: !non-lockfree-atomics

// void wait(T old, memory_order order = memory_order::seq_cst) const volatile noexcept;
// void wait(T old, memory_order order = memory_order::seq_cst) const noexcept;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do these tests start passing if we simply start linking libatomic?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we already automatically link libatomic: #67799, or does the feature not cover these tests? (if I'm reading it correctly, it's applied to all tests unconditionally, but I could well be missing something)

// XFAIL: !non-lockfree-atomics
// XFAIL: !has-128-bit-atomics

// <atomic>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//

// XFAIL: !non-lockfree-atomics
// XFAIL: !has-128-bit-atomics

// <atomic>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//

// XFAIL: !non-lockfree-atomics
// XFAIL: !has-128-bit-atomics

// <atomic>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//

// XFAIL: !non-lockfree-atomics
// XFAIL: !has-128-bit-atomics

// <atomic>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//

// XFAIL: !non-lockfree-atomics
// XFAIL: !has-128-bit-atomics

// <atomic>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//

// XFAIL: !non-lockfree-atomics
// XFAIL: !has-128-bit-atomics

// <atomic>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//

// XFAIL: !non-lockfree-atomics
// XFAIL: !has-128-bit-atomics
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS

// <atomic>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//

// XFAIL: !is-lockfree-runtime-function
// XFAIL: !has-128-bit-atomics

// <atomic>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//

// XFAIL: !non-lockfree-atomics
// XFAIL: !has-128-bit-atomics

// <atomic>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//

// XFAIL: !non-lockfree-atomics
// XFAIL: !has-128-bit-atomics

// <atomic>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//

// XFAIL: !non-lockfree-atomics
// XFAIL: !has-128-bit-atomics

// <atomic>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//

// XFAIL: !non-lockfree-atomics
// XFAIL: !has-128-bit-atomics

// <atomic>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
//
// UNSUPPORTED: no-threads
// XFAIL: c++03
// XFAIL: !non-lockfree-atomics
// XFAIL: !has-128-bit-atomics

// XFAIL: availability-synchronization_library-missing

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
//
// UNSUPPORTED: no-threads
// XFAIL: c++03
// XFAIL: !non-lockfree-atomics
// XFAIL: !has-128-bit-atomics

// XFAIL: availability-synchronization_library-missing

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
//
// UNSUPPORTED: no-threads
// XFAIL: c++03
// XFAIL: !non-lockfree-atomics
// XFAIL: !has-128-bit-atomics

// XFAIL: availability-synchronization_library-missing

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
//
// UNSUPPORTED: no-threads
// XFAIL: c++03
// XFAIL: !non-lockfree-atomics
// XFAIL: !has-128-bit-atomics

// XFAIL: availability-synchronization_library-missing

Expand Down
5 changes: 1 addition & 4 deletions libcxx/test/support/atomic_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,7 @@ struct TestEachAtomicType {
TestFunctor<UserAtomicType>()();
/*
Note: These aren't going to be lock-free,
so some libatomic.a is necessary. To handle
the case where the support functions are
missing, all tests that use this file should add:
XFAIL: !non-lockfree-atomics
so some libatomic.a is necessary.
*/
TestFunctor<LargeUserAtomicType>()();
/*
Expand Down
27 changes: 7 additions & 20 deletions libcxx/utils/libcxx/test/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,25 +183,26 @@ def _getAndroidDeviceApi(cfg):
actions=[AddLinkFlag("-latomic")],
),
Feature(
name="non-lockfree-atomics",
name="has-64-bit-atomics",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this name is both an improvement (because it calls out the size being the factor here), but also gets worse because locking atomics are still atomic. I wouldn't understand the meaning of this feature check if I were just reading it in the test.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the realization here is that the previous name non-lockfree-atomics was entirely wrong. In theory, if a system supported lockfree atomic operations for sizeof(int)*100, this feature would have a downright incorrect name.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does it mean to have has-64-bit-atomics?

I guess I still don't understand the fundamental underlying property we're trying to observe.

when=lambda cfg: sourceBuilds(
cfg,
"""
#include <atomic>
struct Large { int storage[100]; };
struct Large { char storage[64/8]; };
std::atomic<Large> x;
int main(int, char**) { (void)x.load(); return 0; }
int main(int, char**) { (void)x.load(); (void)x.is_lock_free(); return 0; }
""",
),
),
Feature(
name="has-64-bit-atomics",
name="has-128-bit-atomics",
when=lambda cfg: sourceBuilds(
cfg,
"""
#include <atomic>
std::atomic_uint64_t x;
int main(int, char**) { (void)x.load(); return 0; }
struct Large { char storage[128/8]; };
std::atomic<Large> x;
int main(int, char**) { (void)x.load(); (void)x.is_lock_free(); return 0; }
""",
),
),
Expand All @@ -217,20 +218,6 @@ def _getAndroidDeviceApi(cfg):
""",
),
),
# TODO: Remove this feature once compiler-rt includes __atomic_is_lockfree()
# on all supported platforms.
Feature(
name="is-lockfree-runtime-function",
when=lambda cfg: sourceBuilds(
cfg,
"""
#include <atomic>
struct Large { int storage[100]; };
std::atomic<Large> x;
int main(int, char**) { return x.is_lock_free(); }
""",
),
),
# Check for a Windows UCRT bug (fixed in UCRT/Windows 10.0.20348.0):
# https://developercommunity.visualstudio.com/t/utf-8-locales-break-ctype-functions-for-wchar-type/1653678
Feature(
Expand Down