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