summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/Statistic.cpp
diff options
context:
space:
mode:
authorJan Wen Voung <jvoung@google.com>2013-03-08 22:56:31 +0000
committerJan Wen Voung <jvoung@google.com>2013-03-08 22:56:31 +0000
commit7857a64909a317db9746207da633432fe15e8939 (patch)
tree266f2310a25555b1e88ea793eb0eb820148e4120 /llvm/lib/Support/Statistic.cpp
parent51c3318b0197a3e9c37d673450e45bffcbf5e2ff (diff)
downloadbcm5719-llvm-7857a64909a317db9746207da633432fe15e8939.tar.gz
bcm5719-llvm-7857a64909a317db9746207da633432fe15e8939.zip
Disable statistics on Release builds and move tests that depend on -stats.
Summary: Statistics are still available in Release+Asserts (any +Asserts builds), and stats can also be turned on with LLVM_ENABLE_STATS. Move some of the FastISel stats that were moved under DEBUG() back out of DEBUG(), since stats are disabled across the board now. Many tests depend on grepping "-stats" output. Move those into a orig_dir/Stats/. so that they can be marked as unsupported when building without statistics. Differential Revision: http://llvm-reviews.chandlerc.com/D486 llvm-svn: 176733
Diffstat (limited to 'llvm/lib/Support/Statistic.cpp')
-rw-r--r--llvm/lib/Support/Statistic.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/llvm/lib/Support/Statistic.cpp b/llvm/lib/Support/Statistic.cpp
index 3a6522101d6..9c28176b730 100644
--- a/llvm/lib/Support/Statistic.cpp
+++ b/llvm/lib/Support/Statistic.cpp
@@ -40,7 +40,9 @@ namespace llvm { extern raw_ostream *CreateInfoOutputFile(); }
/// what they did.
///
static cl::opt<bool>
-Enabled("stats", cl::desc("Enable statistics output from program"));
+Enabled(
+ "stats",
+ cl::desc("Enable statistics output from program (available with Asserts)"));
namespace {
@@ -142,6 +144,7 @@ void llvm::PrintStatistics(raw_ostream &OS) {
}
void llvm::PrintStatistics() {
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_STATS)
StatisticInfo &Stats = *StatInfo;
// Statistics not enabled?
@@ -151,4 +154,17 @@ void llvm::PrintStatistics() {
raw_ostream &OutStream = *CreateInfoOutputFile();
PrintStatistics(OutStream);
delete &OutStream; // Close the file.
+#else
+ // Check if the -stats option is set instead of checking
+ // !Stats.Stats.empty(). In release builds, Statistics operators
+ // do nothing, so stats are never Registered.
+ if (Enabled) {
+ // Get the stream to write to.
+ raw_ostream &OutStream = *CreateInfoOutputFile();
+ OutStream << "Statistics are disabled. "
+ << "Build with asserts or with -DLLVM_ENABLE_STATS\n";
+ OutStream.flush();
+ delete &OutStream; // Close the file.
+ }
+#endif
}
OpenPOWER on IntegriCloud