summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/llvm/Support/Timer.h6
-rw-r--r--lib/Support/Statistic.cpp2
-rw-r--r--lib/Support/Timer.cpp18
3 files changed, 15 insertions, 11 deletions
diff --git a/include/llvm/Support/Timer.h b/include/llvm/Support/Timer.h
index aba31506fc..2997a8744c 100644
--- a/include/llvm/Support/Timer.h
+++ b/include/llvm/Support/Timer.h
@@ -171,6 +171,7 @@ public:
explicit TimerGroup(const TimerGroup &TG) : FirstTimer(0) {
operator=(TG);
}
+ ~TimerGroup();
void operator=(const TimerGroup &TG) {
assert(TG.FirstTimer == 0 && FirstTimer == 0 &&
@@ -181,11 +182,6 @@ public:
void setName(const std::string &name) { Name = name; }
- ~TimerGroup() {
- assert(FirstTimer == 0 &&
- "TimerGroup destroyed before all contained timers!");
- }
-
void PrintQueuedTimers(raw_ostream &OS);
private:
diff --git a/lib/Support/Statistic.cpp b/lib/Support/Statistic.cpp
index e787670459..f88094af74 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 cc903805e8..daafd63dd2 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.
}