[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 03:52:54 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:

Yeah, I was being too 'clever' here making the final printf output a different message depending on whether the new function was used or we fell back to the old behaviour.

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


More information about the llvm-commits mailing list