diff options
Diffstat (limited to 'llvm/lib/Support')
| -rw-r--r-- | llvm/lib/Support/ManagedStatic.cpp | 8 | ||||
| -rw-r--r-- | llvm/lib/Support/Valgrind.cpp | 11 | 
2 files changed, 18 insertions, 1 deletions
diff --git a/llvm/lib/Support/ManagedStatic.cpp b/llvm/lib/Support/ManagedStatic.cpp index c767c15e71c..098cccb68df 100644 --- a/llvm/lib/Support/ManagedStatic.cpp +++ b/llvm/lib/Support/ManagedStatic.cpp @@ -27,8 +27,15 @@ void ManagedStaticBase::RegisterManagedStatic(void *(*Creator)(),      if (Ptr == 0) {        void* tmp = Creator ? Creator() : 0; +      TsanHappensBefore(this);        sys::MemoryFence(); + +      // This write is racy against the first read in the ManagedStatic +      // accessors. The race is benign because it does a second read after a +      // memory fence, at which point it isn't possible to get a partial value. +      TsanIgnoreWritesBegin();        Ptr = tmp; +      TsanIgnoreWritesEnd();        DeleterFn = Deleter;        // Add to list of managed statics. @@ -72,4 +79,3 @@ void llvm::llvm_shutdown() {    if (llvm_is_multithreaded()) llvm_stop_multithreaded();  } - diff --git a/llvm/lib/Support/Valgrind.cpp b/llvm/lib/Support/Valgrind.cpp index 703448524ed..078d705183d 100644 --- a/llvm/lib/Support/Valgrind.cpp +++ b/llvm/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) {} +}  | 

