mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-03 00:33:09 +00:00
Allow the PassRegistry mutex to be lazily initialized, and clean up the global namespace at the same time.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114131 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
1e3e6362c8
commit
f56ba2b061
@ -34,7 +34,7 @@ PassRegistry *PassRegistry::getPassRegistry() {
|
|||||||
return &*PassRegistryObj;
|
return &*PassRegistryObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
sys::SmartMutex<true> Lock;
|
static ManagedStatic<sys::SmartMutex<true> > Lock;
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// PassRegistryImpl
|
// PassRegistryImpl
|
||||||
@ -68,21 +68,21 @@ void *PassRegistry::getImpl() const {
|
|||||||
//
|
//
|
||||||
|
|
||||||
PassRegistry::~PassRegistry() {
|
PassRegistry::~PassRegistry() {
|
||||||
sys::SmartScopedLock<true> Guard(Lock);
|
sys::SmartScopedLock<true> Guard(*Lock);
|
||||||
PassRegistryImpl *Impl = static_cast<PassRegistryImpl*>(pImpl);
|
PassRegistryImpl *Impl = static_cast<PassRegistryImpl*>(pImpl);
|
||||||
if (Impl) delete Impl;
|
if (Impl) delete Impl;
|
||||||
pImpl = 0;
|
pImpl = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const PassInfo *PassRegistry::getPassInfo(const void *TI) const {
|
const PassInfo *PassRegistry::getPassInfo(const void *TI) const {
|
||||||
sys::SmartScopedLock<true> Guard(Lock);
|
sys::SmartScopedLock<true> Guard(*Lock);
|
||||||
PassRegistryImpl *Impl = static_cast<PassRegistryImpl*>(getImpl());
|
PassRegistryImpl *Impl = static_cast<PassRegistryImpl*>(getImpl());
|
||||||
PassRegistryImpl::MapType::const_iterator I = Impl->PassInfoMap.find(TI);
|
PassRegistryImpl::MapType::const_iterator I = Impl->PassInfoMap.find(TI);
|
||||||
return I != Impl->PassInfoMap.end() ? I->second : 0;
|
return I != Impl->PassInfoMap.end() ? I->second : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const PassInfo *PassRegistry::getPassInfo(StringRef Arg) const {
|
const PassInfo *PassRegistry::getPassInfo(StringRef Arg) const {
|
||||||
sys::SmartScopedLock<true> Guard(Lock);
|
sys::SmartScopedLock<true> Guard(*Lock);
|
||||||
PassRegistryImpl *Impl = static_cast<PassRegistryImpl*>(getImpl());
|
PassRegistryImpl *Impl = static_cast<PassRegistryImpl*>(getImpl());
|
||||||
PassRegistryImpl::StringMapType::const_iterator
|
PassRegistryImpl::StringMapType::const_iterator
|
||||||
I = Impl->PassInfoStringMap.find(Arg);
|
I = Impl->PassInfoStringMap.find(Arg);
|
||||||
@ -94,7 +94,7 @@ const PassInfo *PassRegistry::getPassInfo(StringRef Arg) const {
|
|||||||
//
|
//
|
||||||
|
|
||||||
void PassRegistry::registerPass(const PassInfo &PI) {
|
void PassRegistry::registerPass(const PassInfo &PI) {
|
||||||
sys::SmartScopedLock<true> Guard(Lock);
|
sys::SmartScopedLock<true> Guard(*Lock);
|
||||||
PassRegistryImpl *Impl = static_cast<PassRegistryImpl*>(getImpl());
|
PassRegistryImpl *Impl = static_cast<PassRegistryImpl*>(getImpl());
|
||||||
bool Inserted =
|
bool Inserted =
|
||||||
Impl->PassInfoMap.insert(std::make_pair(PI.getTypeInfo(),&PI)).second;
|
Impl->PassInfoMap.insert(std::make_pair(PI.getTypeInfo(),&PI)).second;
|
||||||
@ -108,7 +108,7 @@ void PassRegistry::registerPass(const PassInfo &PI) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PassRegistry::unregisterPass(const PassInfo &PI) {
|
void PassRegistry::unregisterPass(const PassInfo &PI) {
|
||||||
sys::SmartScopedLock<true> Guard(Lock);
|
sys::SmartScopedLock<true> Guard(*Lock);
|
||||||
PassRegistryImpl *Impl = static_cast<PassRegistryImpl*>(getImpl());
|
PassRegistryImpl *Impl = static_cast<PassRegistryImpl*>(getImpl());
|
||||||
PassRegistryImpl::MapType::iterator I =
|
PassRegistryImpl::MapType::iterator I =
|
||||||
Impl->PassInfoMap.find(PI.getTypeInfo());
|
Impl->PassInfoMap.find(PI.getTypeInfo());
|
||||||
@ -120,7 +120,7 @@ void PassRegistry::unregisterPass(const PassInfo &PI) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PassRegistry::enumerateWith(PassRegistrationListener *L) {
|
void PassRegistry::enumerateWith(PassRegistrationListener *L) {
|
||||||
sys::SmartScopedLock<true> Guard(Lock);
|
sys::SmartScopedLock<true> Guard(*Lock);
|
||||||
PassRegistryImpl *Impl = static_cast<PassRegistryImpl*>(getImpl());
|
PassRegistryImpl *Impl = static_cast<PassRegistryImpl*>(getImpl());
|
||||||
for (PassRegistryImpl::MapType::const_iterator I = Impl->PassInfoMap.begin(),
|
for (PassRegistryImpl::MapType::const_iterator I = Impl->PassInfoMap.begin(),
|
||||||
E = Impl->PassInfoMap.end(); I != E; ++I)
|
E = Impl->PassInfoMap.end(); I != E; ++I)
|
||||||
@ -147,7 +147,7 @@ void PassRegistry::registerAnalysisGroup(const void *InterfaceID,
|
|||||||
assert(ImplementationInfo &&
|
assert(ImplementationInfo &&
|
||||||
"Must register pass before adding to AnalysisGroup!");
|
"Must register pass before adding to AnalysisGroup!");
|
||||||
|
|
||||||
sys::SmartScopedLock<true> Guard(Lock);
|
sys::SmartScopedLock<true> Guard(*Lock);
|
||||||
|
|
||||||
// Make sure we keep track of the fact that the implementation implements
|
// Make sure we keep track of the fact that the implementation implements
|
||||||
// the interface.
|
// the interface.
|
||||||
@ -170,13 +170,13 @@ void PassRegistry::registerAnalysisGroup(const void *InterfaceID,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PassRegistry::addRegistrationListener(PassRegistrationListener *L) {
|
void PassRegistry::addRegistrationListener(PassRegistrationListener *L) {
|
||||||
sys::SmartScopedLock<true> Guard(Lock);
|
sys::SmartScopedLock<true> Guard(*Lock);
|
||||||
PassRegistryImpl *Impl = static_cast<PassRegistryImpl*>(getImpl());
|
PassRegistryImpl *Impl = static_cast<PassRegistryImpl*>(getImpl());
|
||||||
Impl->Listeners.push_back(L);
|
Impl->Listeners.push_back(L);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PassRegistry::removeRegistrationListener(PassRegistrationListener *L) {
|
void PassRegistry::removeRegistrationListener(PassRegistrationListener *L) {
|
||||||
sys::SmartScopedLock<true> Guard(Lock);
|
sys::SmartScopedLock<true> Guard(*Lock);
|
||||||
|
|
||||||
// NOTE: This is necessary, because removeRegistrationListener() can be called
|
// NOTE: This is necessary, because removeRegistrationListener() can be called
|
||||||
// as part of the llvm_shutdown sequence. Since we have no control over the
|
// as part of the llvm_shutdown sequence. Since we have no control over the
|
||||||
|
Loading…
x
Reference in New Issue
Block a user