[all-commits] [llvm/llvm-project] 6d3336: [libcxx][atomic] Fix failure mapping in compare_ex...

Jordan Rupprecht via All-commits all-commits at lists.llvm.org
Tue Jun 15 07:56:17 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 6d33362dafb66b3af4717990d9a06450ec13f367
      https://github.com/llvm/llvm-project/commit/6d33362dafb66b3af4717990d9a06450ec13f367
  Author: Jordan Rupprecht <rupprecht at google.com>
  Date:   2021-06-15 (Tue, 15 Jun 2021)

  Changed paths:
    M libcxx/include/atomic
    A libcxx/test/std/atomics/atomics.general/replace_failure_order_codegen.sh.cpp

  Log Message:
  -----------
  [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




More information about the All-commits mailing list