-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[llvm][Timer] Don't print timers in TimerGroup when all Timers are removed #131026
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…moved 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.
@llvm/pr-subscribers-llvm-support Author: Arthur Eubanks (aeubanks) ChangesOnly 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. Full diff: https://github.com/llvm/llvm-project/pull/131026.diff 2 Files Affected:
diff --git a/llvm/lib/Support/Timer.cpp b/llvm/lib/Support/Timer.cpp
index 089dae2886f22..eca726828c697 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) {
diff --git a/llvm/unittests/Support/TimerTest.cpp b/llvm/unittests/Support/TimerTest.cpp
index 5686b394e16cd..612fd7231da70 100644
--- a/llvm/unittests/Support/TimerTest.cpp
+++ b/llvm/unittests/Support/TimerTest.cpp
@@ -66,4 +66,20 @@ TEST(Timer, CheckIfTriggered) {
EXPECT_FALSE(T1.hasTriggered());
}
-} // end anon namespace
+TEST(Timer, TimerGroupTimerDestructed) {
+ testing::internal::CaptureStderr();
+
+ {
+ TimerGroup TG("tg", "desc");
+ {
+ Timer T1("T1", "T1", TG);
+ T1.startTimer();
+ T1.stopTimer();
+ }
+ EXPECT_TRUE(testing::internal::GetCapturedStderr().empty());
+ testing::internal::CaptureStderr();
+ }
+ EXPECT_FALSE(testing::internal::GetCapturedStderr().empty());
+}
+
+} // namespace
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/153/builds/25569 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/92/builds/15241 Here is the relevant piece of the build log for the reference
|
…moved (llvm#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.
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.