[compiler-rt] [TSan] Ignore reads if not stored early (PR #74575)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 6 01:21:33 PST 2023
https://github.com/felilxtomski created https://github.com/llvm/llvm-project/pull/74575
None
>From dd23a5aed8e5d36c59823c438c3b9279f2d6adff Mon Sep 17 00:00:00 2001
From: "felix.tomski" <tomski at itc.rwth-aachen.de>
Date: Thu, 30 Nov 2023 23:23:17 +0100
Subject: [PATCH] Ignore reads if not stored early
---
compiler-rt/lib/tsan/rtl/tsan_rtl_access.cpp | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl_access.cpp b/compiler-rt/lib/tsan/rtl/tsan_rtl_access.cpp
index 8b20984a01000..ed1de7ed3bb17 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_rtl_access.cpp
+++ b/compiler-rt/lib/tsan/rtl/tsan_rtl_access.cpp
@@ -224,6 +224,8 @@ bool CheckRaces(ThreadState* thr, RawShadow* shadow_mem, Shadow cur,
// the current access info, so we are done.
if (LIKELY(stored))
return false;
+ if (LIKELY(typ & kAccessRead))
+ return false;
// Choose a random candidate slot and replace it.
uptr index =
atomic_load_relaxed(&thr->trace_pos) / sizeof(Event) % kShadowCnt;
@@ -345,8 +347,12 @@ STORE : {
const m128 empty = _mm_cmpeq_epi32(shadow, zero);
const int empty_mask = _mm_movemask_epi8(empty);
index = __builtin_ffs(empty_mask);
- if (UNLIKELY(index == 0))
+ if (UNLIKELY(index == 0)) {
+ // If we reach here, we give up storing reads
+ if (typ & kAccessRead)
+ return false;
index = (atomic_load_relaxed(&thr->trace_pos) / 2) % 16;
+ }
}
StoreShadow(&shadow_mem[index / 4], cur.raw());
// We could zero other slots determined by rewrite_mask.
More information about the llvm-commits
mailing list