Add Tsan annotations to the pass system.
authorNick Lewycky <nicholas@mxc.ca>
Thu, 8 Dec 2011 00:15:41 +0000 (00:15 +0000)
committerNick Lewycky <nicholas@mxc.ca>
Thu, 8 Dec 2011 00:15:41 +0000 (00:15 +0000)
Perhaps once(&func) should be hoisted into lib/Support.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@146110 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/PassSupport.h

index 082790956c4672f3ec16f172b8eb6defafe6a2cd..c50c2cc184e3aebeb6eaa86ea8c2d0e90e6c518d 100644 (file)
@@ -25,6 +25,7 @@
 #include "llvm/PassRegistry.h"
 #include "llvm/InitializePasses.h"
 #include "llvm/Support/Atomic.h"
+#include "llvm/Support/Valgrind.h"
 #include <vector>
 
 namespace llvm {
@@ -135,7 +136,10 @@ private:
   if (old_val == 0) { \
     function(Registry); \
     sys::MemoryFence(); \
+    TsanIgnoreWritesBegin(); \
+    TsanHappensBefore(&initialized); \
     initialized = 2; \
+    TsanIgnoreWritesEnd(); \
   } else { \
     sys::cas_flag tmp = initialized; \
     sys::MemoryFence(); \
@@ -143,7 +147,8 @@ private:
       tmp = initialized; \
       sys::MemoryFence(); \
     } \
-  }
+  } \
+  TsanHappensAfter(&initialized);
 
 #define INITIALIZE_PASS(passName, arg, name, cfg, analysis) \
   static void* initialize##passName##PassOnce(PassRegistry &Registry) { \