https://github.com/vitalybuka updated https://github.com/llvm/llvm-project/pull/228602
>From b84da7df4b180844b59c9b60467c932e265c79e9 Mon Sep 17 00:00:00 2001 From: Vitaly Buka <[email protected]> Date: Fri, 2 Oct 2026 18:51:25 -0700 Subject: [PATCH] Convert to cherry-pick Created using spr 1.3.7 --- compiler-rt/lib/tsan/go/tsan_go.cpp | 3 +-- compiler-rt/lib/tsan/rtl/tsan_rtl.cpp | 6 +++--- compiler-rt/lib/tsan/rtl/tsan_rtl.h | 2 +- compiler-rt/lib/tsan/rtl/tsan_rtl_report.cpp | 2 +- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/compiler-rt/lib/tsan/go/tsan_go.cpp b/compiler-rt/lib/tsan/go/tsan_go.cpp index c987ceacaaea0d..5f6cd0465d7a48 100644 --- a/compiler-rt/lib/tsan/go/tsan_go.cpp +++ b/compiler-rt/lib/tsan/go/tsan_go.cpp @@ -303,8 +303,7 @@ void __tsan_go_ignore_sync_begin(ThreadState *thr) { void __tsan_go_ignore_sync_end(ThreadState *thr) { ThreadIgnoreSyncEnd(thr); } void __tsan_report_count(u64 *pn) { - Lock lock(&ctx->report_mtx); - *pn = ctx->nreported; + *pn = atomic_load_relaxed(&ctx->nreported); } } // extern "C" diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl.cpp b/compiler-rt/lib/tsan/rtl/tsan_rtl.cpp index a9147f09e34cba..e00f2ab5917357 100644 --- a/compiler-rt/lib/tsan/rtl/tsan_rtl.cpp +++ b/compiler-rt/lib/tsan/rtl/tsan_rtl.cpp @@ -819,12 +819,12 @@ int Finalize(ThreadState *thr) { ThreadFinalize(thr); - if (ctx->nreported) { + if (u32 nreported = atomic_load_relaxed(&ctx->nreported)) { failed = true; #if !SANITIZER_GO - Printf("ThreadSanitizer: reported %d warnings\n", ctx->nreported); + Printf("ThreadSanitizer: reported %u warnings\n", nreported); #else - Printf("Found %d data race(s)\n", ctx->nreported); + Printf("Found %u data race(s)\n", nreported); #endif } diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl.h b/compiler-rt/lib/tsan/rtl/tsan_rtl.h index 3d1018accafc40..db3c879e9e030b 100644 --- a/compiler-rt/lib/tsan/rtl/tsan_rtl.h +++ b/compiler-rt/lib/tsan/rtl/tsan_rtl.h @@ -318,7 +318,7 @@ struct Context { MetaMap metamap; Mutex report_mtx; - int nreported; + atomic_uint32_t nreported; atomic_uint64_t last_symbolize_time_ns; void *background_thread; diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl_report.cpp b/compiler-rt/lib/tsan/rtl/tsan_rtl_report.cpp index 4e58305b582d5a..3bf1d6a5a81e11 100644 --- a/compiler-rt/lib/tsan/rtl/tsan_rtl_report.cpp +++ b/compiler-rt/lib/tsan/rtl/tsan_rtl_report.cpp @@ -713,7 +713,7 @@ bool OutputReport(ThreadState *thr, ScopedReport &srep) { } PrintReport(rep); __tsan_on_report(rep); - ctx->nreported++; + atomic_fetch_add(&ctx->nreported, 1, memory_order_relaxed); if (flags()->halt_on_error) Die(); thr->current_report = nullptr; _______________________________________________ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
