aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Support
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-03-30 04:58:26 +0000
committerChris Lattner <sabre@nondot.org>2010-03-30 04:58:26 +0000
commit9f9f6d19dd67926446fb89a7b2dc0bda6353645b (patch)
tree118bf5b33e48a6c5bd6d2a36abaf6856a2d0de68 /lib/Support
parentb9312690a2a79de490ab9c439b9b5d7c9319bff8 (diff)
downloadexternal_llvm-9f9f6d19dd67926446fb89a7b2dc0bda6353645b.zip
external_llvm-9f9f6d19dd67926446fb89a7b2dc0bda6353645b.tar.gz
external_llvm-9f9f6d19dd67926446fb89a7b2dc0bda6353645b.tar.bz2
if a timergroup is destroyed before its timers, print times.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99873 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support')
-rw-r--r--lib/Support/Statistic.cpp2
-rw-r--r--lib/Support/Timer.cpp18
2 files changed, 14 insertions, 6 deletions
diff --git a/lib/Support/Statistic.cpp b/lib/Support/Statistic.cpp
index e787670..f88094a 100644
--- a/lib/Support/Statistic.cpp
+++ b/lib/Support/Statistic.cpp
@@ -128,6 +128,6 @@ StatisticInfo::~StatisticInfo() {
OutStream << '\n'; // Flush the output stream...
OutStream.flush();
- if (&OutStream != &outs() && &OutStream != &errs() && &OutStream != &dbgs())
+ if (&OutStream != &outs() && &OutStream != &errs())
delete &OutStream; // Close the file.
}
diff --git a/lib/Support/Timer.cpp b/lib/Support/Timer.cpp
index cc90380..daafd63 100644
--- a/lib/Support/Timer.cpp
+++ b/lib/Support/Timer.cpp
@@ -237,14 +237,22 @@ NamedRegionTimer::NamedRegionTimer(const std::string &Name,
// TimerGroup Implementation
//===----------------------------------------------------------------------===//
+TimerGroup::~TimerGroup() {
+ // If the timer group is destroyed before the timers it owns, accumulate and
+ // print the timing data.
+ while (FirstTimer != 0)
+ removeTimer(*FirstTimer);
+}
+
+
void TimerGroup::removeTimer(Timer &T) {
sys::SmartScopedLock<true> L(*TimerLock);
// If the timer was started, move its data to TimersToPrint.
- if (T.Started) {
- T.Started = false;
+ if (T.Started)
TimersToPrint.push_back(std::make_pair(T.Time, T.Name));
- }
+
+ T.TG = 0;
// Unlink the timer from our list.
*T.Prev = T.Next;
@@ -257,9 +265,9 @@ void TimerGroup::removeTimer(Timer &T) {
return;
raw_ostream *OutStream = GetLibSupportInfoOutputFile();
-
+
PrintQueuedTimers(*OutStream);
-
+
if (OutStream != &errs() && OutStream != &outs())
delete OutStream; // Close the file.
}