mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-04 17:56:53 +00:00
Make the lazy initialization of DefaultTimerGroup threadsafe.
llvm-svn: 73963
This commit is contained in:
parent
58df12c49b
commit
24a1453189
@ -52,8 +52,20 @@ namespace {
|
||||
|
||||
static TimerGroup *DefaultTimerGroup = 0;
|
||||
static TimerGroup *getDefaultTimerGroup() {
|
||||
if (DefaultTimerGroup) return DefaultTimerGroup;
|
||||
return DefaultTimerGroup = new TimerGroup("Miscellaneous Ungrouped Timers");
|
||||
TimerGroup* tmp = DefaultTimerGroup;
|
||||
sys::MemoryFence();
|
||||
if (!tmp) {
|
||||
llvm_acquire_global_lock();
|
||||
tmp = DefaultTimerGroup;
|
||||
if (!tmp) {
|
||||
tmp = new TimerGroup("Miscellaneous Ungrouped Timers");
|
||||
sys::MemoryFence();
|
||||
DefaultTimerGroup = tmp;
|
||||
}
|
||||
llvm_release_global_lock();
|
||||
}
|
||||
|
||||
return tmp;
|
||||
}
|
||||
|
||||
Timer::Timer(const std::string &N)
|
||||
@ -377,11 +389,5 @@ void TimerGroup::removeTimer() {
|
||||
if (OutStream != cerr.stream() && OutStream != cout.stream())
|
||||
delete OutStream; // Close the file...
|
||||
}
|
||||
|
||||
// Delete default timer group!
|
||||
if (NumTimers == 0 && this == DefaultTimerGroup) {
|
||||
delete DefaultTimerGroup;
|
||||
DefaultTimerGroup = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user