1 //===-- StatisticReporter.cpp - Easy way to expose stats information -------==//
3 // This file implements the 'Statistic' class, which is designed to be an easy
4 // way to expose various success metrics from passes. These statistics are
5 // printed at the end of a run, when the -stats command line option is enabled
6 // on the command line.
8 // This is useful for reporting information like the number of instructions
9 // simplified, optimized or removed by various transformations, like this:
11 // static Statistic<> NumInstEliminated("GCSE - Number of instructions killed");
13 // Later, in the code: ++NumInstEliminated;
15 //===----------------------------------------------------------------------===//
17 #include "Support/StatisticReporter.h"
18 #include "Support/CommandLine.h"
21 static cl::Flag Enabled("stats", "Enable statistics output from program");
23 // Print information when destroyed, iff command line option is specified
24 void StatisticBase::destroy() const {
25 if (Enabled && hasSomeData()) {
27 printValue(std::cerr);
29 std::cerr << "\t" << Name << "\n";