diff --git a/bolt/tools/driver/llvm-bolt.cpp b/bolt/tools/driver/llvm-bolt.cpp --- a/bolt/tools/driver/llvm-bolt.cpp +++ b/bolt/tools/driver/llvm-bolt.cpp @@ -182,8 +182,6 @@ sys::PrintStackTraceOnErrorSignal(argv[0]); PrettyStackTraceProgram X(argc, argv); - llvm_shutdown_obj Y; // Call llvm_shutdown() on exit. - std::string ToolPath = GetExecutablePath(argv[0]); // Initialize targets and assembly printers/parsers. diff --git a/bolt/tools/merge-fdata/merge-fdata.cpp b/bolt/tools/merge-fdata/merge-fdata.cpp --- a/bolt/tools/merge-fdata/merge-fdata.cpp +++ b/bolt/tools/merge-fdata/merge-fdata.cpp @@ -315,8 +315,6 @@ sys::PrintStackTraceOnErrorSignal(argv[0]); PrettyStackTraceProgram X(argc, argv); - llvm_shutdown_obj Y; // Call llvm_shutdown() on exit. - cl::HideUnrelatedOptions(opts::MergeFdataCategory); cl::ParseCommandLineOptions(argc, argv, diff --git a/clang/include/clang/Frontend/CompilerInstance.h b/clang/include/clang/Frontend/CompilerInstance.h --- a/clang/include/clang/Frontend/CompilerInstance.h +++ b/clang/include/clang/Frontend/CompilerInstance.h @@ -205,16 +205,10 @@ /// - Clients should have initialized any LLVM target features that may be /// required. /// - /// - Clients should eventually call llvm_shutdown() upon the completion of - /// this routine to ensure that any managed objects are properly destroyed. - /// /// Note that this routine may write output to 'stderr'. /// /// \param Act - The action to execute. /// \return - True on success. - // - // FIXME: Eliminate the llvm_shutdown requirement, that should either be part - // of the context or else not CompilerInstance specific. bool ExecuteAction(FrontendAction &Act); /// Load the list of plugins requested in the \c FrontendOptions. diff --git a/clang/tools/clang-repl/ClangRepl.cpp b/clang/tools/clang-repl/ClangRepl.cpp --- a/clang/tools/clang-repl/ClangRepl.cpp +++ b/clang/tools/clang-repl/ClangRepl.cpp @@ -18,7 +18,6 @@ #include "llvm/ExecutionEngine/Orc/LLJIT.h" #include "llvm/LineEditor/LineEditor.h" #include "llvm/Support/CommandLine.h" -#include "llvm/Support/ManagedStatic.h" // llvm_shutdown #include "llvm/Support/Signals.h" #include "llvm/Support/TargetSelect.h" // llvm::Initialize* @@ -127,7 +126,5 @@ // later errors use the default handling behavior instead. llvm::remove_fatal_error_handler(); - llvm::llvm_shutdown(); - return checkDiagErrors(Interp->getCompilerInstance()); } diff --git a/clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp b/clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp --- a/clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp +++ b/clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp @@ -23,7 +23,6 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/ExecutionEngine/Orc/LLJIT.h" -#include "llvm/Support/ManagedStatic.h" #include "llvm/Support/TargetSelect.h" #include "llvm-c/Error.h" @@ -131,8 +130,6 @@ EXPECT_ANY_THROW(ThrowException()); std::string CapturedStdOut = testing::internal::GetCapturedStdout(); EXPECT_EQ(CapturedStdOut, "Caught: 'To be caught in JIT'\n"); - - llvm::llvm_shutdown(); } } // end anonymous namespace diff --git a/clang/unittests/Interpreter/InterpreterTest.cpp b/clang/unittests/Interpreter/InterpreterTest.cpp --- a/clang/unittests/Interpreter/InterpreterTest.cpp +++ b/clang/unittests/Interpreter/InterpreterTest.cpp @@ -188,7 +188,6 @@ llvm::InitializeNativeTarget(); llvm::InitializeNativeTargetAsmPrinter(); } - ~LLVMInitRAII() { llvm::llvm_shutdown(); } } LLVMInit; #ifdef _AIX diff --git a/clang/utils/TableGen/TableGen.cpp b/clang/utils/TableGen/TableGen.cpp --- a/clang/utils/TableGen/TableGen.cpp +++ b/clang/utils/TableGen/TableGen.cpp @@ -485,8 +485,6 @@ PrettyStackTraceProgram X(argc, argv); cl::ParseCommandLineOptions(argc, argv); - llvm_shutdown_obj Y; - return TableGenMain(argv[0], &ClangTableGenMain); } diff --git a/libclc/utils/prepare-builtins.cpp b/libclc/utils/prepare-builtins.cpp --- a/libclc/utils/prepare-builtins.cpp +++ b/libclc/utils/prepare-builtins.cpp @@ -10,7 +10,6 @@ #include "llvm/IR/LLVMContext.h" #include "llvm/IR/Module.h" #include "llvm/Support/CommandLine.h" -#include "llvm/Support/ManagedStatic.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/raw_ostream.h" @@ -31,7 +30,6 @@ int main(int argc, char **argv) { LLVMContext Context; - llvm_shutdown_obj Y; // Call llvm_shutdown() on exit. cl::ParseCommandLineOptions(argc, argv, "libclc builtin preparation tool\n"); diff --git a/lldb/tools/driver/Driver.cpp b/lldb/tools/driver/Driver.cpp --- a/lldb/tools/driver/Driver.cpp +++ b/lldb/tools/driver/Driver.cpp @@ -780,8 +780,7 @@ std::setlocale(LC_ALL, ""); std::setlocale(LC_CTYPE, ""); - // Setup LLVM signal handlers and make sure we call llvm_shutdown() on - // destruction. + // Setup LLVM signal handlers. llvm::InitLLVM IL(argc, argv, /*InstallPipeSignalExitHandler=*/false); // Parse arguments. diff --git a/lldb/tools/lldb-test/lldb-test.cpp b/lldb/tools/lldb-test/lldb-test.cpp --- a/lldb/tools/lldb-test/lldb-test.cpp +++ b/lldb/tools/lldb-test/lldb-test.cpp @@ -37,7 +37,6 @@ #include "llvm/ADT/ScopeExit.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/CommandLine.h" -#include "llvm/Support/ManagedStatic.h" #include "llvm/Support/MathExtras.h" #include "llvm/Support/Path.h" #include "llvm/Support/PrettyStackTrace.h" @@ -1091,7 +1090,6 @@ StringRef ToolName = argv[0]; sys::PrintStackTraceOnErrorSignal(ToolName); PrettyStackTraceProgram X(argc, argv); - llvm_shutdown_obj Y; cl::ParseCommandLineOptions(argc, argv, "LLDB Testing Utility\n"); diff --git a/lldb/unittests/Utility/LogTest.cpp b/lldb/unittests/Utility/LogTest.cpp --- a/lldb/unittests/Utility/LogTest.cpp +++ b/lldb/unittests/Utility/LogTest.cpp @@ -12,7 +12,6 @@ #include "lldb/Utility/Log.h" #include "lldb/Utility/StreamString.h" #include "llvm/ADT/BitmaskEnum.h" -#include "llvm/Support/ManagedStatic.h" #include "llvm/Support/Threading.h" #include @@ -72,7 +71,6 @@ static void TearDownTestCase() { Log::Unregister("chan"); - llvm::llvm_shutdown(); } }; @@ -142,7 +140,6 @@ } TEST(LogTest, Register) { - llvm::llvm_shutdown_obj obj; Log::Register("chan", test_channel); Log::Unregister("chan"); Log::Register("chan", test_channel); @@ -150,7 +147,6 @@ } TEST(LogTest, Unregister) { - llvm::llvm_shutdown_obj obj; Log::Register("chan", test_channel); EXPECT_EQ(nullptr, GetLog(TestChannel::FOO)); std::string message; diff --git a/lldb/utils/TableGen/LLDBTableGen.cpp b/lldb/utils/TableGen/LLDBTableGen.cpp --- a/lldb/utils/TableGen/LLDBTableGen.cpp +++ b/lldb/utils/TableGen/LLDBTableGen.cpp @@ -68,8 +68,6 @@ PrettyStackTraceProgram X(argc, argv); cl::ParseCommandLineOptions(argc, argv); - llvm_shutdown_obj Y; - return TableGenMain(argv[0], &LLDBTableGenMain); } diff --git a/llvm/examples/BrainF/BrainFDriver.cpp b/llvm/examples/BrainF/BrainFDriver.cpp --- a/llvm/examples/BrainF/BrainFDriver.cpp +++ b/llvm/examples/BrainF/BrainFDriver.cpp @@ -41,7 +41,6 @@ #include "llvm/Support/Casting.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/FileSystem.h" -#include "llvm/Support/ManagedStatic.h" #include "llvm/Support/TargetSelect.h" #include "llvm/Support/raw_ostream.h" #include @@ -180,7 +179,5 @@ if (out != &outs()) delete out; - llvm_shutdown(); - return 0; } diff --git a/llvm/examples/HowToUseJIT/HowToUseJIT.cpp b/llvm/examples/HowToUseJIT/HowToUseJIT.cpp --- a/llvm/examples/HowToUseJIT/HowToUseJIT.cpp +++ b/llvm/examples/HowToUseJIT/HowToUseJIT.cpp @@ -48,7 +48,6 @@ #include "llvm/IR/Module.h" #include "llvm/IR/Type.h" #include "llvm/Support/Casting.h" -#include "llvm/Support/ManagedStatic.h" #include "llvm/Support/TargetSelect.h" #include "llvm/Support/raw_ostream.h" #include @@ -135,6 +134,5 @@ // Import result of execution: outs() << "Result: " << gv.IntVal << "\n"; delete EE; - llvm_shutdown(); return 0; } diff --git a/llvm/include/llvm/PassRegistry.h b/llvm/include/llvm/PassRegistry.h --- a/llvm/include/llvm/PassRegistry.h +++ b/llvm/include/llvm/PassRegistry.h @@ -53,8 +53,8 @@ ~PassRegistry(); /// getPassRegistry - Access the global registry object, which is - /// automatically initialized at application launch and destroyed by - /// llvm_shutdown. + /// automatically initialized at application launch and destroyed when + /// global destructors are run. static PassRegistry *getPassRegistry(); /// getPassInfo - Look up a pass' corresponding PassInfo, indexed by the pass' diff --git a/llvm/include/llvm/Support/DynamicLibrary.h b/llvm/include/llvm/Support/DynamicLibrary.h --- a/llvm/include/llvm/Support/DynamicLibrary.h +++ b/llvm/include/llvm/Support/DynamicLibrary.h @@ -57,7 +57,8 @@ void *getAddressOfSymbol(const char *symbolName); /// This function permanently loads the dynamic library at the given path. - /// The library will only be unloaded when llvm_shutdown() is called. + /// The library will only be unloaded when LLVM's global destructors are + /// run. /// This returns a valid DynamicLibrary instance on success and an invalid /// instance on failure (see isValid()). \p *errMsg will only be modified /// if the library fails to load. diff --git a/llvm/include/llvm/Support/InitLLVM.h b/llvm/include/llvm/Support/InitLLVM.h --- a/llvm/include/llvm/Support/InitLLVM.h +++ b/llvm/include/llvm/Support/InitLLVM.h @@ -29,8 +29,6 @@ // encoding, so that you can assume that command line arguments are // always encoded in UTF-8 on any platform. // -// InitLLVM calls llvm_shutdown() on destruction, which cleans up -// ManagedStatic objects. namespace llvm { class InitLLVM { public: @@ -40,8 +38,6 @@ : InitLLVM(Argc, const_cast(Argv), InstallPipeSignalExitHandler) {} - ~InitLLVM(); - private: BumpPtrAllocator Alloc; SmallVector Args; diff --git a/llvm/lib/IR/Pass.cpp b/llvm/lib/IR/Pass.cpp --- a/llvm/lib/IR/Pass.cpp +++ b/llvm/lib/IR/Pass.cpp @@ -227,8 +227,8 @@ } // This only gets called during static destruction, in which case the -// PassRegistry will have already been destroyed by llvm_shutdown(). So -// attempting to remove the registration listener is an error. +// PassRegistry may have already been destroyed. So attempting to remove the +// registration listener is an error (and also unnecessary). PassNameParser::~PassNameParser() = default; //===----------------------------------------------------------------------===// diff --git a/llvm/lib/Support/InitLLVM.cpp b/llvm/lib/Support/InitLLVM.cpp --- a/llvm/lib/Support/InitLLVM.cpp +++ b/llvm/lib/Support/InitLLVM.cpp @@ -9,7 +9,6 @@ #include "llvm/Support/InitLLVM.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/ErrorHandling.h" -#include "llvm/Support/ManagedStatic.h" #include "llvm/Support/PrettyStackTrace.h" #include "llvm/Support/Signals.h" #include "llvm/Support/SwapByteOrder.h" @@ -60,5 +59,3 @@ Argv = Args.data(); #endif } - -InitLLVM::~InitLLVM() { llvm_shutdown(); } diff --git a/llvm/lib/Support/Unix/DynamicLibrary.inc b/llvm/lib/Support/Unix/DynamicLibrary.inc --- a/llvm/lib/Support/Unix/DynamicLibrary.inc +++ b/llvm/lib/Support/Unix/DynamicLibrary.inc @@ -20,7 +20,7 @@ if (Process) ::dlclose(Process); - // llvm_shutdown called, Return to default + // Global destructors run, Return to default DynamicLibrary::SearchOrder = DynamicLibrary::SO_Linker; } diff --git a/llvm/lib/Support/Unix/Signals.inc b/llvm/lib/Support/Unix/Signals.inc --- a/llvm/lib/Support/Unix/Signals.inc +++ b/llvm/lib/Support/Unix/Signals.inc @@ -13,13 +13,7 @@ // // This file is extremely careful to only do signal-safe things while in a // signal handler. In particular, memory allocation and acquiring a mutex -// while in a signal handler should never occur. ManagedStatic isn't usable from -// a signal handler for 2 reasons: -// -// 1. Creating a new one allocates. -// 2. The signal handler could fire while llvm_shutdown is being processed, in -// which case the ManagedStatic is in an unknown state because it could -// already have been destroyed, or be in the process of being destroyed. +// while in a signal handler should never occur. // // Modifying the behavior of the signal handlers (such as registering new ones) // can acquire a mutex, but all this guarantees is that the signal handler @@ -191,8 +185,9 @@ static std::atomic FilesToRemove = ATOMIC_VAR_INIT(nullptr); /// Clean up the list in a signal-friendly manner. -/// Recall that signals can fire during llvm_shutdown. If this occurs we should -/// either clean something up or nothing at all, but we shouldn't crash! +/// Recall that signals can fire while global destructors are run. If this +/// occurs we should either clean something up or nothing at all, but we +/// shouldn't crash! struct FilesToRemoveCleanup { // Not signal-safe. ~FilesToRemoveCleanup() { diff --git a/llvm/lib/Support/Windows/DynamicLibrary.inc b/llvm/lib/Support/Windows/DynamicLibrary.inc --- a/llvm/lib/Support/Windows/DynamicLibrary.inc +++ b/llvm/lib/Support/Windows/DynamicLibrary.inc @@ -28,7 +28,7 @@ // 'Process' should not be released on Windows. assert((!Process || Process==this) && "Bad Handle"); - // llvm_shutdown called, Return to default + // Global destructors run, Return to default DynamicLibrary::SearchOrder = DynamicLibrary::SO_Linker; } diff --git a/llvm/tools/gold/gold-plugin.cpp b/llvm/tools/gold/gold-plugin.cpp --- a/llvm/tools/gold/gold-plugin.cpp +++ b/llvm/tools/gold/gold-plugin.cpp @@ -27,7 +27,6 @@ #include "llvm/Support/CommandLine.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Host.h" -#include "llvm/Support/ManagedStatic.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Path.h" #include "llvm/Support/TargetSelect.h" @@ -1139,7 +1138,6 @@ return LDPS_OK; if (options::thinlto_index_only) { - llvm_shutdown(); cleanup_hook(); exit(0); } @@ -1157,7 +1155,6 @@ static ld_plugin_status all_symbols_read_hook(void) { ld_plugin_status Ret = allSymbolsReadHook(); - llvm_shutdown(); if (options::TheOutputType == options::OT_BC_ONLY || options::TheOutputType == options::OT_ASM_ONLY || diff --git a/llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp b/llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp --- a/llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp +++ b/llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp @@ -18,7 +18,6 @@ #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" #include "llvm/Support/Format.h" -#include "llvm/Support/ManagedStatic.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/PrettyStackTrace.h" #include "llvm/Support/Regex.h" @@ -435,7 +434,6 @@ // Print a stack trace if we signal out. sys::PrintStackTraceOnErrorSignal(argv[0]); PrettyStackTraceProgram X(argc, argv); - llvm_shutdown_obj Y; // Call llvm_shutdown() on exit. llvm::InitializeAllTargets(); diff --git a/llvm/unittests/ExecutionEngine/ExecutionEngineTest.cpp b/llvm/unittests/ExecutionEngine/ExecutionEngineTest.cpp --- a/llvm/unittests/ExecutionEngine/ExecutionEngineTest.cpp +++ b/llvm/unittests/ExecutionEngine/ExecutionEngineTest.cpp @@ -14,7 +14,6 @@ #include "llvm/IR/LLVMContext.h" #include "llvm/IR/Module.h" #include "llvm/Support/DynamicLibrary.h" -#include "llvm/Support/ManagedStatic.h" #include "gtest/gtest.h" using namespace llvm; @@ -22,9 +21,6 @@ namespace { class ExecutionEngineTest : public testing::Test { -private: - llvm_shutdown_obj Y; // Call llvm_shutdown() on exit. - protected: ExecutionEngineTest() { auto Owner = std::make_unique("
", Context); diff --git a/llvm/unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp b/llvm/unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp --- a/llvm/unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp +++ b/llvm/unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp @@ -9,7 +9,6 @@ #include "llvm/Support/DynamicLibrary.h" #include "llvm/Config/config.h" #include "llvm/Support/FileSystem.h" -#include "llvm/Support/ManagedStatic.h" #include "llvm/Support/Path.h" #include "gtest/gtest.h" @@ -59,7 +58,6 @@ TEST(DynamicLibrary, Overload) { { std::string Err; - llvm_shutdown_obj Shutdown; DynamicLibrary DL = DynamicLibrary::getPermanentLibrary(LibPath().c_str(), &Err); EXPECT_TRUE(DL.isValid()); @@ -109,9 +107,6 @@ } EXPECT_TRUE(FuncPtr(DynamicLibrary::SearchForAddressOfSymbol( "TestA")) == nullptr); - - // Check serach ordering is reset to default after call to llvm_shutdown - EXPECT_EQ(DynamicLibrary::SearchOrder, DynamicLibrary::SO_Linker); } TEST(DynamicLibrary, Shutdown) { @@ -119,7 +114,6 @@ std::vector Order; { std::string Err; - llvm_shutdown_obj Shutdown; DynamicLibrary DL = DynamicLibrary::getPermanentLibrary(LibPath(A).c_str(), &Err); EXPECT_TRUE(DL.isValid()); diff --git a/llvm/utils/KillTheDoctor/KillTheDoctor.cpp b/llvm/utils/KillTheDoctor/KillTheDoctor.cpp --- a/llvm/utils/KillTheDoctor/KillTheDoctor.cpp +++ b/llvm/utils/KillTheDoctor/KillTheDoctor.cpp @@ -36,7 +36,6 @@ #include "llvm/ADT/StringRef.h" #include "llvm/ADT/Twine.h" #include "llvm/Support/CommandLine.h" -#include "llvm/Support/ManagedStatic.h" #include "llvm/Support/Path.h" #include "llvm/Support/PrettyStackTrace.h" #include "llvm/Support/Signals.h" @@ -297,7 +296,6 @@ // Print a stack trace if we signal out. sys::PrintStackTraceOnErrorSignal(argv[0]); PrettyStackTraceProgram X(argc, argv); - llvm_shutdown_obj Y; // Call llvm_shutdown() on exit. ToolName = argv[0]; diff --git a/mlir/tools/mlir-vulkan-runner/mlir-vulkan-runner.cpp b/mlir/tools/mlir-vulkan-runner/mlir-vulkan-runner.cpp --- a/mlir/tools/mlir-vulkan-runner/mlir-vulkan-runner.cpp +++ b/mlir/tools/mlir-vulkan-runner/mlir-vulkan-runner.cpp @@ -62,7 +62,6 @@ } int main(int argc, char **argv) { - llvm::llvm_shutdown_obj x; registerPassManagerCLOptions(); llvm::InitLLVM y(argc, argv); diff --git a/polly/lib/External/isl/interface/extract_interface.cc b/polly/lib/External/isl/interface/extract_interface.cc --- a/polly/lib/External/isl/interface/extract_interface.cc +++ b/polly/lib/External/isl/interface/extract_interface.cc @@ -48,7 +48,6 @@ #include #include #include -#include #include #include #include