[PATCH] D28367: Correct default TimerGroup singleton to use magic-statics so that it gets cleaned up
Erich Keane via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 16 12:31:30 PST 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL295370: Change default TimerGroup singleton to use magic statics (authored by erichkeane).
Changed prior to commit:
https://reviews.llvm.org/D28367?vs=83270&id=88765#toc
Repository:
rL LLVM
https://reviews.llvm.org/D28367
Files:
llvm/trunk/lib/Support/Timer.cpp
Index: llvm/trunk/lib/Support/Timer.cpp
===================================================================
--- llvm/trunk/lib/Support/Timer.cpp
+++ llvm/trunk/lib/Support/Timer.cpp
@@ -72,22 +72,9 @@
return llvm::make_unique<raw_fd_ostream>(2, false); // stderr.
}
-
-static TimerGroup *DefaultTimerGroup = nullptr;
static TimerGroup *getDefaultTimerGroup() {
- TimerGroup *tmp = DefaultTimerGroup;
- sys::MemoryFence();
- if (tmp) return tmp;
-
- sys::SmartScopedLock<true> Lock(*TimerLock);
- tmp = DefaultTimerGroup;
- if (!tmp) {
- tmp = new TimerGroup("misc", "Miscellaneous Ungrouped Timers");
- sys::MemoryFence();
- DefaultTimerGroup = tmp;
- }
-
- return tmp;
+ static TimerGroup DefaultTimerGroup("misc", "Miscellaneous Ungrouped Timers");
+ return &DefaultTimerGroup;
}
//===----------------------------------------------------------------------===//
@@ -309,7 +296,7 @@
// If this is not an collection of ungrouped times, print the total time.
// Ungrouped timers don't really make sense to add up. We still print the
// TOTAL line to make the percentages make sense.
- if (this != DefaultTimerGroup)
+ if (this != getDefaultTimerGroup())
OS << format(" Total Execution Time: %5.4f seconds (%5.4f wall clock)\n",
Total.getProcessTime(), Total.getWallTime());
OS << '\n';
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28367.88765.patch
Type: text/x-patch
Size: 1353 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170216/3d743516/attachment.bin>
More information about the llvm-commits
mailing list