diff options
author | Arthur Eubanks <aeubanks@google.com> | 2025-03-12 16:20:13 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-12 16:20:13 -0700 |
commit | 1cfca53b9f2eadbf864b85995ec7f819d7f29b5e (patch) | |
tree | d1b05f73dfff61e03317ef7669671b419a2a47c6 /llvm/lib/Support/Timer.cpp | |
parent | c14e459ef8bd8b0cf1d2b135f570f39868b6fee6 (diff) | |
download | llvm-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.cpp | 13 |
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) { |