[clang] [llvm] [llvm][NFC] Rework Timer.cpp globals to ensure valid lifetimes (PR #121663)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 10 06:40:17 PST 2025
================
@@ -115,22 +92,12 @@ std::unique_ptr<raw_ostream> llvm::CreateInfoOutputFile() {
return std::make_unique<raw_fd_ostream>(2, false); // stderr.
}
-namespace {
-struct CreateDefaultTimerGroup {
- static void *call() {
- return new TimerGroup("misc", "Miscellaneous Ungrouped Timers");
- }
-};
-} // namespace
-static ManagedStatic<TimerGroup, CreateDefaultTimerGroup> DefaultTimerGroup;
-static TimerGroup *getDefaultTimerGroup() { return &*DefaultTimerGroup; }
-
//===----------------------------------------------------------------------===//
// Timer Implementation
//===----------------------------------------------------------------------===//
void Timer::init(StringRef TimerName, StringRef TimerDescription) {
- init(TimerName, TimerDescription, *getDefaultTimerGroup());
----------------
macurtis-amd wrote:
> Does the new mtg::DefaultTimerGroup() introduce extra overhead?
I didn't measure it, but i think at most it is the overhead of is a one or two function calls.
> I presume that the new code retains this mechanism
Yes.
https://github.com/llvm/llvm-project/pull/121663
More information about the llvm-commits
mailing list