[all-commits] [llvm/llvm-project] 1893b6: Avoid triggering assert when program calls OSAtomi...

Julian Lettner via All-commits all-commits at lists.llvm.org
Tue Jul 13 09:34:12 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 1893b630fec06947b4f59e43c00db4d787f39262
      https://github.com/llvm/llvm-project/commit/1893b630fec06947b4f59e43c00db4d787f39262
  Author: Julian Lettner <julian.lettner at apple.com>
  Date:   2021-07-13 (Tue, 13 Jul 2021)

  Changed paths:
    M compiler-rt/lib/tsan/rtl/tsan_interceptors_mac.cpp

  Log Message:
  -----------
  Avoid triggering assert when program calls OSAtomicCompareAndSwapLong

A previous change brought the new, relaxed implementation of "on failure
memory ordering" for synchronization primitives in LLVM over to TSan
land [1].  It included the following assert:
```
// 31.7.2.18: "The failure argument shall not be memory_order_release
// nor memory_order_acq_rel". LLVM (2021-05) fallbacks to Monotonic
// (mo_relaxed) when those are used.
CHECK(IsLoadOrder(fmo));

static bool IsLoadOrder(morder mo) {
  return mo == mo_relaxed || mo == mo_consume
      || mo == mo_acquire || mo == mo_seq_cst;
}
```

A previous workaround for a false positive when using an old Darwin
synchronization API assumed this failure mode to be unused and passed a
dummy value [2].  We update this value to `mo_relaxed` which is also the
value used by the actual implementation to avoid triggering the assert.

[1] https://reviews.llvm.org/D99434
[2] https://reviews.llvm.org/D21733

rdar://78122243

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




More information about the All-commits mailing list