Index: llvm/lib/Support/ManagedStatic.cpp =================================================================== --- llvm/lib/Support/ManagedStatic.cpp +++ llvm/lib/Support/ManagedStatic.cpp @@ -18,23 +18,13 @@ using namespace llvm; static const ManagedStaticBase *StaticList = nullptr; -static std::recursive_mutex *ManagedStaticMutex = nullptr; -static llvm::once_flag mutex_init_flag; - -static void initializeMutex() { - ManagedStaticMutex = new std::recursive_mutex(); -} - -static std::recursive_mutex *getManagedStaticMutex() { - llvm::call_once(mutex_init_flag, initializeMutex); - return ManagedStaticMutex; -} +static std::recursive_mutex ManagedStaticMutex; void ManagedStaticBase::RegisterManagedStatic(void *(*Creator)(), void (*Deleter)(void*)) const { assert(Creator); if (llvm_is_multithreaded()) { - std::lock_guard Lock(*getManagedStaticMutex()); + std::lock_guard Lock(ManagedStaticMutex); if (!Ptr.load(std::memory_order_relaxed)) { void *Tmp = Creator(); @@ -76,7 +66,7 @@ /// llvm_shutdown - Deallocate and destroy all ManagedStatic variables. void llvm::llvm_shutdown() { - std::lock_guard Lock(*getManagedStaticMutex()); + std::lock_guard Lock(ManagedStaticMutex); while (StaticList) StaticList->destroy();