[Openmp-commits] [openmp] [OMPT] Set default values for tsan function pointers (PR #93568)
via Openmp-commits
openmp-commits at lists.llvm.org
Tue May 28 10:38:03 PDT 2024
================
@@ -146,18 +146,27 @@ void __attribute__((weak)) __tsan_flush_memory() {}
static ArcherFlags *archer_flags;
#ifndef TsanHappensBefore
+
+template <typename... Args> static void __tsan_func(Args...) {}
+
+#define DECLARE_TSAN_FUNCTION(name, ...) \
+ static void (*name)(__VA_ARGS__) = __tsan_func<__VA_ARGS__>;
+
// Thread Sanitizer is a tool that finds races in code.
// See http://code.google.com/p/data-race-test/wiki/DynamicAnnotations .
// tsan detects these exact functions by name.
extern "C" {
-static void (*AnnotateHappensAfter)(const char *, int, const volatile void *);
-static void (*AnnotateHappensBefore)(const char *, int, const volatile void *);
-static void (*AnnotateIgnoreWritesBegin)(const char *, int);
-static void (*AnnotateIgnoreWritesEnd)(const char *, int);
-static void (*AnnotateNewMemory)(const char *, int, const volatile void *,
- size_t);
-static void (*__tsan_func_entry)(const void *);
-static void (*__tsan_func_exit)(void);
+DECLARE_TSAN_FUNCTION(AnnotateHappensAfter, const char *, int,
+ const volatile void *)
+DECLARE_TSAN_FUNCTION(AnnotateHappensBefore, const char *, int,
+ const volatile void *)
+DECLARE_TSAN_FUNCTION(AnnotateIgnoreWritesBegin, const char *, int)
+DECLARE_TSAN_FUNCTION(AnnotateIgnoreWritesEnd, const char *, int)
+DECLARE_TSAN_FUNCTION(AnnotateNewMemory, const char *, int,
+ const volatile void *, size_t)
+DECLARE_TSAN_FUNCTION(__tsan_func_entry, const void *)
+DECLARE_TSAN_FUNCTION(__tsan_func_exit)
+
----------------
jprotze wrote:
```suggestion
// RunningOnValgrind is used to detect absence of TSan and must intentionally be a nullptr.
```
https://github.com/llvm/llvm-project/pull/93568
More information about the Openmp-commits
mailing list