[compiler-rt] [TSan] Add interceptor for os_unfair_lock_lock_with_flags (PR #153815)

Dan Blackwell via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 19 04:02:29 PDT 2025


================
@@ -23,6 +36,28 @@ int main() {
   pthread_join(t1, NULL);
   pthread_join(t2, NULL);
   fprintf(stderr, "global_variable = %ld\n", global_variable);
+
+  // CHECK: global_variable = 2
+
+  void *(*func)(void *) = Thread;
+  char flags_available = 0;
+#if defined(__MAC_15_0)
+#  pragma clang diagnostic push
+#  pragma clang diagnostic ignored "-Wunguarded-availability-new"
+  if (&os_unfair_lock_lock_with_flags) {
+#  pragma clang diagnostic pop
+    func = ThreadWithFlags;
+    flags_available = 1;
+  }
+#endif
----------------
DanBlackwell wrote:

> The reason for the complication here is so we pass the 2nd CHECK: global_variable = 4, right?

Yeah, but we can just do all the logic within ThreadWithFlags

https://github.com/llvm/llvm-project/pull/153815


More information about the llvm-commits mailing list