[llvm] r210717 - Don't acquire the mutex during the destructor of PassRegistry.

David Blaikie dblaikie at gmail.com
Wed Jun 11 17:01:37 PDT 2014


On Wed, Jun 11, 2014 at 4:03 PM, Zachary Turner <zturner at google.com> wrote:
> Author: zturner
> Date: Wed Jun 11 18:03:31 2014
> New Revision: 210717
>
> URL: http://llvm.org/viewvc/llvm-project?rev=210717&view=rev
> Log:
> 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.

Yep. All that. Thanks!

>
> Modified:
>     llvm/trunk/lib/IR/PassRegistry.cpp
>
> Modified: llvm/trunk/lib/IR/PassRegistry.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/PassRegistry.cpp?rev=210717&r1=210716&r2=210717&view=diff
> ==============================================================================
> --- llvm/trunk/lib/IR/PassRegistry.cpp (original)
> +++ llvm/trunk/lib/IR/PassRegistry.cpp Wed Jun 11 18:03:31 2014
> @@ -73,7 +73,10 @@ void *PassRegistry::getImpl() const {
>  //
>
>  PassRegistry::~PassRegistry() {
> -  sys::SmartScopedWriter<true> 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<PassRegistryImpl*>(pImpl);
>    delete Impl;
>    pImpl = nullptr;
>
>
> _______________________________________________
> 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