Eliminate redundant bitwise operations when using a llvm/ADT/PointerUnion.
[oota-llvm.git] / include / llvm / ADT / Statistic.h
index 9bbda986a819e9becf1cf082a4d84f3615f68f59..b54d10b9dd334d0317054f81c82c3504a3517007 100644 (file)
@@ -27,6 +27,7 @@
 #define LLVM_ADT_STATISTIC_H
 
 #include "llvm/Support/Atomic.h"
+#include "llvm/Support/Valgrind.h"
 
 namespace llvm {
 class raw_ostream;
@@ -84,11 +85,13 @@ public:
   }
 
   const Statistic &operator+=(const unsigned &V) {
+    if (!V) return *this;
     sys::AtomicAdd(&Value, V);
     return init();
   }
 
   const Statistic &operator-=(const unsigned &V) {
+    if (!V) return *this;
     sys::AtomicAdd(&Value, -V);
     return init();
   }
@@ -108,6 +111,7 @@ protected:
     bool tmp = Initialized;
     sys::MemoryFence();
     if (!tmp) RegisterStatistic();
+    TsanHappensAfter(this);
     return *this;
   }
   void RegisterStatistic();