X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=include%2Fllvm%2FADT%2FStatistic.h;h=b54d10b9dd334d0317054f81c82c3504a3517007;hb=acb8d9fbe3853394a2537985349993580309b8cd;hp=9bbda986a819e9becf1cf082a4d84f3615f68f59;hpb=b35e4e84727ff5ba3621b39caa622baef431ca45;p=oota-llvm.git diff --git a/include/llvm/ADT/Statistic.h b/include/llvm/ADT/Statistic.h index 9bbda986a81..b54d10b9dd3 100644 --- a/include/llvm/ADT/Statistic.h +++ b/include/llvm/ADT/Statistic.h @@ -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();