diff options
author | Chris Lattner <sabre@nondot.org> | 2010-03-30 04:58:26 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-03-30 04:58:26 +0000 |
commit | dcd68b7a658dc95d3e14104ae16c2b36424b78b6 (patch) | |
tree | 266046944256322ebd75a6b3eefb80db64e39503 /llvm/lib/Support/Timer.cpp | |
parent | 9a608d248e093e1808572e9e4dfaebf5ac7c1dd1 (diff) | |
download | llvm-dcd68b7a658dc95d3e14104ae16c2b36424b78b6.zip llvm-dcd68b7a658dc95d3e14104ae16c2b36424b78b6.tar.gz llvm-dcd68b7a658dc95d3e14104ae16c2b36424b78b6.tar.bz2 |
if a timergroup is destroyed before its timers, print times.
llvm-svn: 99873
Diffstat (limited to 'llvm/lib/Support/Timer.cpp')
-rw-r--r-- | llvm/lib/Support/Timer.cpp | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/llvm/lib/Support/Timer.cpp b/llvm/lib/Support/Timer.cpp index cc90380..daafd63 100644 --- a/llvm/lib/Support/Timer.cpp +++ b/llvm/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. } |