[llvm-commits] [llvm] r114131 - /llvm/trunk/lib/VMCore/PassRegistry.cpp

Chris Lattner clattner at apple.com
Thu Sep 16 17:53:42 PDT 2010


On Sep 16, 2010, at 4:44 PM, Owen Anderson wrote:

> Author: resistor
> Date: Thu Sep 16 18:44:50 2010
> New Revision: 114131
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=114131&view=rev
> Log:
> Allow the PassRegistry mutex to be lazily initialized, and clean up the global namespace at the same time.

Thanks!  Next question, why not ManagedStatic<PassRegistryImpl> and put the lock in PassRegistryImpl?

-Chris

> 
> Modified:
>    llvm/trunk/lib/VMCore/PassRegistry.cpp
> 
> Modified: llvm/trunk/lib/VMCore/PassRegistry.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/PassRegistry.cpp?rev=114131&r1=114130&r2=114131&view=diff
> ==============================================================================
> --- llvm/trunk/lib/VMCore/PassRegistry.cpp (original)
> +++ llvm/trunk/lib/VMCore/PassRegistry.cpp Thu Sep 16 18:44:50 2010
> @@ -34,7 +34,7 @@
>   return &*PassRegistryObj;
> }
> 
> -sys::SmartMutex<true> Lock;
> +static ManagedStatic<sys::SmartMutex<true> > Lock;
> 
> //===----------------------------------------------------------------------===//
> // PassRegistryImpl
> @@ -68,21 +68,21 @@
> //
> 
> PassRegistry::~PassRegistry() {
> -  sys::SmartScopedLock<true> Guard(Lock);
> +  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);
> +  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);
> +  sys::SmartScopedLock<true> Guard(*Lock);
>   PassRegistryImpl *Impl = static_cast<PassRegistryImpl*>(getImpl());
>   PassRegistryImpl::StringMapType::const_iterator
>     I = Impl->PassInfoStringMap.find(Arg);
> @@ -94,7 +94,7 @@
> //
> 
> void PassRegistry::registerPass(const PassInfo &PI) {
> -  sys::SmartScopedLock<true> Guard(Lock);
> +  sys::SmartScopedLock<true> Guard(*Lock);
>   PassRegistryImpl *Impl = static_cast<PassRegistryImpl*>(getImpl());
>   bool Inserted =
>     Impl->PassInfoMap.insert(std::make_pair(PI.getTypeInfo(),&PI)).second;
> @@ -108,7 +108,7 @@
> }
> 
> void PassRegistry::unregisterPass(const PassInfo &PI) {
> -  sys::SmartScopedLock<true> Guard(Lock);
> +  sys::SmartScopedLock<true> Guard(*Lock);
>   PassRegistryImpl *Impl = static_cast<PassRegistryImpl*>(getImpl());
>   PassRegistryImpl::MapType::iterator I = 
>     Impl->PassInfoMap.find(PI.getTypeInfo());
> @@ -120,7 +120,7 @@
> }
> 
> void PassRegistry::enumerateWith(PassRegistrationListener *L) {
> -  sys::SmartScopedLock<true> Guard(Lock);
> +  sys::SmartScopedLock<true> Guard(*Lock);
>   PassRegistryImpl *Impl = static_cast<PassRegistryImpl*>(getImpl());
>   for (PassRegistryImpl::MapType::const_iterator I = Impl->PassInfoMap.begin(),
>        E = Impl->PassInfoMap.end(); I != E; ++I)
> @@ -147,7 +147,7 @@
>     assert(ImplementationInfo &&
>            "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
>     // the interface.
> @@ -170,13 +170,13 @@
> }
> 
> void PassRegistry::addRegistrationListener(PassRegistrationListener *L) {
> -  sys::SmartScopedLock<true> Guard(Lock);
> +  sys::SmartScopedLock<true> Guard(*Lock);
>   PassRegistryImpl *Impl = static_cast<PassRegistryImpl*>(getImpl());
>   Impl->Listeners.push_back(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
>   // as part of the llvm_shutdown sequence.  Since we have no control over the
> 
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits





More information about the llvm-commits mailing list