#include "llvm/System/Atomic.h"
namespace llvm {
+class raw_ostream;
class Statistic {
public:
const char *Name;
const char *Desc;
- unsigned Value;
+ volatile llvm::sys::cas_flag Value;
bool Initialized;
- unsigned getValue() const { return Value; }
+ llvm::sys::cas_flag getValue() const { return Value; }
const char *getName() const { return Name; }
const char *getDesc() const { return Desc; }
}
const Statistic &operator++() {
+ // FIXME: This function and all those that follow carefully use an
+ // atomic operation to update the value safely in the presence of
+ // concurrent accesses, but not to read the return value, so the
+ // return value is not thread safe.
sys::AtomicIncrement(&Value);
return init();
}
#define STATISTIC(VARNAME, DESC) \
static llvm::Statistic VARNAME = { DEBUG_TYPE, DESC, 0, 0 }
+/// \brief Enable the collection and printing of statistics.
+void EnableStatistics();
+
+/// \brief Print statistics to the file returned by CreateInfoOutputFile().
+void PrintStatistics();
+
+/// \brief Print statistics to the given output stream.
+void PrintStatistics(raw_ostream &OS);
+
} // End llvm namespace
#endif