Index: lib/Support/ManagedStatic.cpp =================================================================== --- lib/Support/ManagedStatic.cpp +++ lib/Support/ManagedStatic.cpp @@ -77,8 +77,13 @@ /// llvm_shutdown - Deallocate and destroy all ManagedStatic variables. void llvm::llvm_shutdown() { - MutexGuard Lock(*getManagedStaticMutex()); + { + MutexGuard Lock(*getManagedStaticMutex()); + + while (StaticList) + StaticList->destroy(); + } - while (StaticList) - StaticList->destroy(); + delete ManagedStaticMutex; + ManagedStaticMutex = nullptr; }