aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Support/Timer.cpp
diff options
context:
space:
mode:
authorArthur Eubanks <aeubanks@google.com>2025-03-12 16:20:13 -0700
committerGitHub <noreply@github.com>2025-03-12 16:20:13 -0700
commit1cfca53b9f2eadbf864b85995ec7f819d7f29b5e (patch)
treed1b05f73dfff61e03317ef7669671b419a2a47c6 /llvm/lib/Support/Timer.cpp
parentc14e459ef8bd8b0cf1d2b135f570f39868b6fee6 (diff)
downloadllvm-1cfca53b9f2eadbf864b85995ec7f819d7f29b5e.zip
llvm-1cfca53b9f2eadbf864b85995ec7f819d7f29b5e.tar.gz
llvm-1cfca53b9f2eadbf864b85995ec7f819d7f29b5e.tar.bz2
[llvm][Timer] Don't print timers in TimerGroup when all Timers are removed (#131026)
Only print them on TimerGroup destruction (or eagerly when TimerGroup::printAll() is called). We should be able to destroy all Timers in a TimerGroup while delaying printing the stored TimeRecords.
Diffstat (limited to 'llvm/lib/Support/Timer.cpp')
-rw-r--r--llvm/lib/Support/Timer.cpp13
1 files changed, 5 insertions, 8 deletions
diff --git a/llvm/lib/Support/Timer.cpp b/llvm/lib/Support/Timer.cpp
index 089dae2..eca7268 100644
--- a/llvm/lib/Support/Timer.cpp
+++ b/llvm/lib/Support/Timer.cpp
@@ -284,6 +284,11 @@ TimerGroup::~TimerGroup() {
while (FirstTimer)
removeTimer(*FirstTimer);
+ if (!TimersToPrint.empty()) {
+ std::unique_ptr<raw_ostream> OutStream = CreateInfoOutputFile();
+ PrintQueuedTimers(*OutStream);
+ }
+
// Remove the group from the TimerGroupList.
sys::SmartScopedLock<true> L(timerLock());
*Prev = Next;
@@ -305,14 +310,6 @@ void TimerGroup::removeTimer(Timer &T) {
*T.Prev = T.Next;
if (T.Next)
T.Next->Prev = T.Prev;
-
- // Print the report when all timers in this group are destroyed if some of
- // them were started.
- if (FirstTimer || TimersToPrint.empty())
- return;
-
- std::unique_ptr<raw_ostream> OutStream = CreateInfoOutputFile();
- PrintQueuedTimers(*OutStream);
}
void TimerGroup::addTimer(Timer &T) {