HomePhabricator

[libcxx][atomic] Fix failure mapping in compare_exchange_{strong,weak}.

Authored by rupprecht on Jun 15 2021, 7:55 AM.

Description

[libcxx][atomic] Fix failure mapping in compare_exchange_{strong,weak}.

https://eel.is/c++draft/atomics.types.operations#23 says: ... the value of failure is order except that a value of memory_order::acq_rel shall be replaced by the value memory_order::acquire and a value of memory_order::release shall be replaced by the value memory_order::relaxed.

This failure mapping is only handled for _LIBCPP_HAS_GCC_ATOMIC_IMP. We are seeing bad code generation for compare_exchange_strong(cmp, 1, std::memory_order_acq_rel) when using libc++ in place of libstdc++: https://godbolt.org/z/v3onrrq4G.

This was caught by tsan tests after D99434, [TSAN] Honor failure memory orders in AtomicCAS, but appears to be an issue in non-tsan code.

Reviewed By: ldionne, dvyukov

Differential Revision: https://reviews.llvm.org/D103846

Details

Committed
rupprechtJun 15 2021, 7:55 AM
Reviewer
ldionne
Differential Revision
D103846: [libcxx][atomic] Fix failure mapping in compare_exchange_{strong,weak}.
Parents
rGe893708aac04: [mlir] Avoid GCC naming conflict.
Branches
Unknown
Tags
Unknown