[all-commits] [llvm/llvm-project] 9e3e97: tsan: refactor MetaMap::GetAndLock interface

Dmitry Vyukov via All-commits all-commits at lists.llvm.org
Mon Aug 2 04:30:00 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 9e3e97aa810acac7b8ecffa7d4a92f55966e5358
      https://github.com/llvm/llvm-project/commit/9e3e97aa810acac7b8ecffa7d4a92f55966e5358
  Author: Dmitry Vyukov <dvyukov at google.com>
  Date:   2021-08-02 (Mon, 02 Aug 2021)

  Changed paths:
    M compiler-rt/lib/sanitizer_common/sanitizer_mutex.h
    M compiler-rt/lib/tsan/rtl/tsan_interface_atomic.cpp
    M compiler-rt/lib/tsan/rtl/tsan_rtl_mutex.cpp
    M compiler-rt/lib/tsan/rtl/tsan_rtl_report.cpp
    M compiler-rt/lib/tsan/rtl/tsan_sync.cpp
    M compiler-rt/lib/tsan/rtl/tsan_sync.h
    M compiler-rt/lib/tsan/tests/unit/tsan_sync_test.cpp

  Log Message:
  -----------
  tsan: refactor MetaMap::GetAndLock interface

Don't lock the sync object inside of MetaMap methods.
This has several advantages:
 - the new interface does not confuse thread-safety analysis
   so we can remove a bunch of NO_THREAD_SAFETY_ANALYSIS attributes
 - this allows use of scoped lock objects
 - this allows more flexibility, e.g. locking some other mutex
   between searching and locking the sync object
Also prefix the methods with GetSync to be consistent with GetBlock method.
Also make interface wrappers inlinable, otherwise we either end up with
2 copies of the method, or with an additional call.

Reviewed By: melver

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




More information about the All-commits mailing list