Author: Sunho Kim Date: 2022-06-26T22:10:28+09:00 New Revision: 45b6c38145e72d8a2593f9637c01015122b0b28c
URL: https://github.com/llvm/llvm-project/commit/45b6c38145e72d8a2593f9637c01015122b0b28c DIFF: https://github.com/llvm/llvm-project/commit/45b6c38145e72d8a2593f9637c01015122b0b28c.diff LOG: Revert "[clang-repl] Support destructors of global objects." This reverts commit 9de8b05bfe0de2915d2443d06159396c5f9d389f. Added: Modified: clang/lib/Interpreter/IncrementalExecutor.cpp clang/lib/Interpreter/IncrementalExecutor.h clang/lib/Interpreter/Interpreter.cpp clang/test/Interpreter/execute.cpp clang/tools/clang-repl/ClangRepl.cpp clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp Removed: ################################################################################ diff --git a/clang/lib/Interpreter/IncrementalExecutor.cpp b/clang/lib/Interpreter/IncrementalExecutor.cpp index 2445ba906a4c2..c055827281b4f 100644 --- a/clang/lib/Interpreter/IncrementalExecutor.cpp +++ b/clang/lib/Interpreter/IncrementalExecutor.cpp @@ -53,12 +53,6 @@ IncrementalExecutor::IncrementalExecutor(llvm::orc::ThreadSafeContext &TSC, IncrementalExecutor::~IncrementalExecutor() {} -// Clean up the JIT instance. -llvm::Error IncrementalExecutor::cleanUp() { - // This calls the global dtors of registered modules. - return Jit->deinitialize(Jit->getMainJITDylib()); -} - llvm::Error IncrementalExecutor::addModule(PartialTranslationUnit &PTU) { llvm::orc::ResourceTrackerSP RT = Jit->getMainJITDylib().createResourceTracker(); diff --git a/clang/lib/Interpreter/IncrementalExecutor.h b/clang/lib/Interpreter/IncrementalExecutor.h index fd93b1d390357..580724e1e24e2 100644 --- a/clang/lib/Interpreter/IncrementalExecutor.h +++ b/clang/lib/Interpreter/IncrementalExecutor.h @@ -51,7 +51,6 @@ class IncrementalExecutor { llvm::Error addModule(PartialTranslationUnit &PTU); llvm::Error removeModule(PartialTranslationUnit &PTU); llvm::Error runCtors() const; - llvm::Error cleanUp(); llvm::Expected<llvm::JITTargetAddress> getSymbolAddress(llvm::StringRef Name, SymbolNameKind NameKind) const; llvm::orc::LLJIT *getExecutionEngine() const { return Jit.get(); } diff --git a/clang/lib/Interpreter/Interpreter.cpp b/clang/lib/Interpreter/Interpreter.cpp index 0ffb40c217cd9..a10eb79b413b3 100644 --- a/clang/lib/Interpreter/Interpreter.cpp +++ b/clang/lib/Interpreter/Interpreter.cpp @@ -183,14 +183,7 @@ Interpreter::Interpreter(std::unique_ptr<CompilerInstance> CI, *TSCtx->getContext(), Err); } -Interpreter::~Interpreter() { - if (IncrExecutor) { - if (llvm::Error Err = IncrExecutor->cleanUp()) - llvm::report_fatal_error( - llvm::Twine("Failed to clean up IncrementalExecutor: ") + - toString(std::move(Err))); - } -} +Interpreter::~Interpreter() {} llvm::Expected<std::unique_ptr<Interpreter>> Interpreter::create(std::unique_ptr<CompilerInstance> CI) { diff --git a/clang/test/Interpreter/execute.cpp b/clang/test/Interpreter/execute.cpp index 914a9285117e0..f5c70c21ac507 100644 --- a/clang/test/Interpreter/execute.cpp +++ b/clang/test/Interpreter/execute.cpp @@ -1,4 +1,3 @@ -// clang-format off // RUN: clang-repl "int x = 10;" "int y=7; err;" "int y = 10;" // RUN: clang-repl "int i = 10;" 'extern "C" int printf(const char*,...);' \ // RUN: 'auto r1 = printf("i = %d\n", i);' | FileCheck --check-prefix=CHECK-DRIVER %s @@ -19,7 +18,4 @@ auto r2 = printf("S[f=%f, m=0x%llx]\n", s.f, reinterpret_cast<unsigned long long inline int foo() { return 42; } int r3 = foo(); -struct D { float f = 1.0; D *m = nullptr; D(){} ~D() { printf("D[f=%f, m=0x%llx]\n", f, reinterpret_cast<unsigned long long>(m)); }} d; -// CHECK: D[f=1.000000, m=0x0] - %quit diff --git a/clang/tools/clang-repl/ClangRepl.cpp b/clang/tools/clang-repl/ClangRepl.cpp index d3253738c6da1..4f673bdcb7cc5 100644 --- a/clang/tools/clang-repl/ClangRepl.cpp +++ b/clang/tools/clang-repl/ClangRepl.cpp @@ -70,8 +70,6 @@ int main(int argc, const char **argv) { ExitOnErr.setBanner("clang-repl: "); llvm::cl::ParseCommandLineOptions(argc, argv); - llvm::llvm_shutdown_obj Y; // Call llvm_shutdown() on exit. - std::vector<const char *> ClangArgv(ClangArgs.size()); std::transform(ClangArgs.begin(), ClangArgs.end(), ClangArgv.begin(), [](const std::string &s) -> const char * { return s.data(); }); @@ -129,5 +127,7 @@ int main(int argc, const char **argv) { // 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 index 73f7a01a20bf0..75928d912dd47 100644 --- a/clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp +++ b/clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp @@ -48,7 +48,6 @@ createInterpreter(const Args &ExtraArgs = {}, TEST(InterpreterTest, CatchException) { llvm::InitializeNativeTarget(); llvm::InitializeNativeTargetAsmPrinter(); - llvm::llvm_shutdown_obj Y; // Call llvm_shutdown() on exit. { auto J = llvm::orc::LLJITBuilder().create(); @@ -132,6 +131,8 @@ extern "C" int throw_exception() { 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 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits