summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2010-09-16 23:32:35 +0000
committerOwen Anderson <resistor@mac.com>2010-09-16 23:32:35 +0000
commitd8788271079e5cf9dc9122078a1a8aabfdc5d032 (patch)
tree9d5d7ccb196e6d251aef2aba1613f3accc4ca263
parentd8e7922ba23740fb73a7a9d33048751169ed7b3c (diff)
downloadbcm5719-llvm-d8788271079e5cf9dc9122078a1a8aabfdc5d032.tar.gz
bcm5719-llvm-d8788271079e5cf9dc9122078a1a8aabfdc5d032.zip
Do not expose the locking for the PassRegistry in the header. Be careful to
synchronize any method that might lazily initialize the pImpl. llvm-svn: 114130
-rw-r--r--llvm/include/llvm/PassRegistry.h2
-rw-r--r--llvm/lib/VMCore/PassRegistry.cpp9
2 files changed, 8 insertions, 3 deletions
diff --git a/llvm/include/llvm/PassRegistry.h b/llvm/include/llvm/PassRegistry.h
index 8b7f036e20c..31d48a4e28f 100644
--- a/llvm/include/llvm/PassRegistry.h
+++ b/llvm/include/llvm/PassRegistry.h
@@ -18,7 +18,6 @@
#define LLVM_PASSREGISTRY_H
#include "llvm/ADT/StringRef.h"
-#include "llvm/System/Mutex.h"
namespace llvm {
@@ -33,7 +32,6 @@ struct PassRegistrationListener;
/// each thread.
class PassRegistry {
mutable void *pImpl;
- mutable sys::SmartMutex<true> Lock;
void *getImpl() const;
public:
diff --git a/llvm/lib/VMCore/PassRegistry.cpp b/llvm/lib/VMCore/PassRegistry.cpp
index 0b4e59dc0e6..61565770226 100644
--- a/llvm/lib/VMCore/PassRegistry.cpp
+++ b/llvm/lib/VMCore/PassRegistry.cpp
@@ -16,6 +16,7 @@
#include "llvm/PassSupport.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/ManagedStatic.h"
+#include "llvm/System/Mutex.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/StringMap.h"
@@ -33,6 +34,8 @@ PassRegistry *PassRegistry::getPassRegistry() {
return &*PassRegistryObj;
}
+sys::SmartMutex<true> Lock;
+
//===----------------------------------------------------------------------===//
// PassRegistryImpl
//
@@ -65,18 +68,21 @@ void *PassRegistry::getImpl() const {
//
PassRegistry::~PassRegistry() {
+ sys::SmartScopedLock<true> Guard(Lock);
PassRegistryImpl *Impl = static_cast<PassRegistryImpl*>(pImpl);
if (Impl) delete Impl;
pImpl = 0;
}
const PassInfo *PassRegistry::getPassInfo(const void *TI) const {
+ sys::SmartScopedLock<true> Guard(Lock);
PassRegistryImpl *Impl = static_cast<PassRegistryImpl*>(getImpl());
PassRegistryImpl::MapType::const_iterator I = Impl->PassInfoMap.find(TI);
return I != Impl->PassInfoMap.end() ? I->second : 0;
}
const PassInfo *PassRegistry::getPassInfo(StringRef Arg) const {
+ sys::SmartScopedLock<true> Guard(Lock);
PassRegistryImpl *Impl = static_cast<PassRegistryImpl*>(getImpl());
PassRegistryImpl::StringMapType::const_iterator
I = Impl->PassInfoStringMap.find(Arg);
@@ -127,7 +133,6 @@ void PassRegistry::registerAnalysisGroup(const void *InterfaceID,
const void *PassID,
PassInfo& Registeree,
bool isDefault) {
- sys::SmartScopedLock<true> Guard(Lock);
PassInfo *InterfaceInfo = const_cast<PassInfo*>(getPassInfo(InterfaceID));
if (InterfaceInfo == 0) {
// First reference to Interface, register it now.
@@ -142,6 +147,8 @@ void PassRegistry::registerAnalysisGroup(const void *InterfaceID,
assert(ImplementationInfo &&
"Must register pass before adding to AnalysisGroup!");
+ sys::SmartScopedLock<true> Guard(Lock);
+
// Make sure we keep track of the fact that the implementation implements
// the interface.
ImplementationInfo->addInterfaceImplemented(InterfaceInfo);
OpenPOWER on IntegriCloud