1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 11:02:59 +02:00

[Timer] Move DefaultTimerGroup into a ManagedStatic.

This used to be just leaked. r295370 made it use magic statics. This adds
a global destructor, which is something we'd like to avoid. It also creates
a weird situation where the mutex used by TimerGroup is re-created during
global shutdown and leaked.

Using a ManagedStatic here is also subtle as it relies on the mutex
inside of ManagedStatic to be recursive. I've added a test for that
in a previous change.

llvm-svn: 304156
This commit is contained in:
Benjamin Kramer 2017-05-29 14:05:29 +00:00
parent b4108258ab
commit 8bf13d6351

View File

@ -72,10 +72,11 @@ std::unique_ptr<raw_fd_ostream> llvm::CreateInfoOutputFile() {
return llvm::make_unique<raw_fd_ostream>(2, false); // stderr.
}
static TimerGroup *getDefaultTimerGroup() {
static TimerGroup DefaultTimerGroup("misc", "Miscellaneous Ungrouped Timers");
return &DefaultTimerGroup;
static void *CreateDefaultTimerGroup() {
return new TimerGroup("misc", "Miscellaneous Ungrouped Timers");
}
static ManagedStatic<TimerGroup, CreateDefaultTimerGroup> DefaultTimerGroup;
static TimerGroup *getDefaultTimerGroup() { return &*DefaultTimerGroup; }
//===----------------------------------------------------------------------===//
// Timer Implementation