From: Zachary Turner Date: Wed, 11 Jun 2014 23:03:31 +0000 (+0000) Subject: Don't acquire the mutex during the destructor of PassRegistry. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=a8763052319c654b924f052f55998e040a11b3f6;p=oota-llvm.git Don't acquire the mutex during the destructor of PassRegistry. This destructor is run as part of static program termination, and so all ManagedStatics (including this lock) will have been destroyed by llvm_shutdown. Furthermore, if there is actually a race condition during static program termination, then we are just hiding a bug somewhere else, because other threads should not be running at this point. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210717 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/IR/PassRegistry.cpp b/lib/IR/PassRegistry.cpp index 6a5bee2f57b..e85fabffb8c 100644 --- a/lib/IR/PassRegistry.cpp +++ b/lib/IR/PassRegistry.cpp @@ -73,7 +73,10 @@ void *PassRegistry::getImpl() const { // PassRegistry::~PassRegistry() { - sys::SmartScopedWriter Guard(*Lock); + // Don't acquire the mutex here. This is destroyed during static execution of + // static destructors, after llvm_shutdown() has been called, so all instances + // of all ManagedStatics (including the Mutex), will have been destroyed as + // well. PassRegistryImpl *Impl = static_cast(pImpl); delete Impl; pImpl = nullptr;