From 4d0a9ff36574da0c042e9bd3ae816301b392ac41 Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Mon, 14 Nov 2011 20:50:16 +0000 Subject: Add support for tsan annotations (thread sanitizer, a valgrind-based tool). These annotations are disabled entirely when either ENABLE_THREADS is off, or building a release build. When enabled, they add calls to functions with no statements to ManagedStatic's getters. Use these annotations to inform tsan that the race used inside ManagedStatic initialization is actually benign. Thanks to Kostya Serebryany for helping write this patch! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@144567 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/Valgrind.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'lib/Support/Valgrind.cpp') diff --git a/lib/Support/Valgrind.cpp b/lib/Support/Valgrind.cpp index 7034485..078d705 100644 --- a/lib/Support/Valgrind.cpp +++ b/lib/Support/Valgrind.cpp @@ -52,3 +52,14 @@ void llvm::sys::ValgrindDiscardTranslations(const void *Addr, size_t Len) { } #endif // !HAVE_VALGRIND_VALGRIND_H + +// These functions require no implementation, tsan just looks at the arguments +// they're called with. +extern "C" { +void AnnotateHappensBefore(const char *file, int line, + const volatile void *cv) {} +void AnnotateHappensAfter(const char *file, int line, + const volatile void *cv) {} +void AnnotateIgnoreWritesBegin(const char *file, int line) {} +void AnnotateIgnoreWritesEnd(const char *file, int line) {} +} -- cgit v1.1 From ec381a4183f70122305f810c6b11b8f0e3bf83c0 Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Tue, 15 Nov 2011 00:14:04 +0000 Subject: Fix linking for some users who already have tsan enabled code and are trying to link it against llvm code, by making our definitions weak. "Some users." git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@144596 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/Valgrind.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'lib/Support/Valgrind.cpp') diff --git a/lib/Support/Valgrind.cpp b/lib/Support/Valgrind.cpp index 078d705..46d93a2 100644 --- a/lib/Support/Valgrind.cpp +++ b/lib/Support/Valgrind.cpp @@ -56,10 +56,10 @@ void llvm::sys::ValgrindDiscardTranslations(const void *Addr, size_t Len) { // These functions require no implementation, tsan just looks at the arguments // they're called with. extern "C" { -void AnnotateHappensBefore(const char *file, int line, - const volatile void *cv) {} -void AnnotateHappensAfter(const char *file, int line, - const volatile void *cv) {} -void AnnotateIgnoreWritesBegin(const char *file, int line) {} -void AnnotateIgnoreWritesEnd(const char *file, int line) {} +LLVM_ATTRIBUTE_WEAK void AnnotateHappensBefore(const char *file, int line, + const volatile void *cv) {} +LLVM_ATTRIBUTE_WEAK void AnnotateHappensAfter(const char *file, int line, + const volatile void *cv) {} +LLVM_ATTRIBUTE_WEAK void AnnotateIgnoreWritesBegin(const char *file, int line){} +LLVM_ATTRIBUTE_WEAK void AnnotateIgnoreWritesEnd(const char *file, int line) {} } -- cgit v1.1 From e7c1aef2b824f29ea92b2b324975915fe2115fa4 Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Tue, 15 Nov 2011 01:23:22 +0000 Subject: Move WEAK marking to the declaration. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@144603 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/Valgrind.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'lib/Support/Valgrind.cpp') diff --git a/lib/Support/Valgrind.cpp b/lib/Support/Valgrind.cpp index 46d93a2..078d705 100644 --- a/lib/Support/Valgrind.cpp +++ b/lib/Support/Valgrind.cpp @@ -56,10 +56,10 @@ void llvm::sys::ValgrindDiscardTranslations(const void *Addr, size_t Len) { // These functions require no implementation, tsan just looks at the arguments // they're called with. extern "C" { -LLVM_ATTRIBUTE_WEAK void AnnotateHappensBefore(const char *file, int line, - const volatile void *cv) {} -LLVM_ATTRIBUTE_WEAK void AnnotateHappensAfter(const char *file, int line, - const volatile void *cv) {} -LLVM_ATTRIBUTE_WEAK void AnnotateIgnoreWritesBegin(const char *file, int line){} -LLVM_ATTRIBUTE_WEAK void AnnotateIgnoreWritesEnd(const char *file, int line) {} +void AnnotateHappensBefore(const char *file, int line, + const volatile void *cv) {} +void AnnotateHappensAfter(const char *file, int line, + const volatile void *cv) {} +void AnnotateIgnoreWritesBegin(const char *file, int line) {} +void AnnotateIgnoreWritesEnd(const char *file, int line) {} } -- cgit v1.1