[llvm-branch-commits] [clang] aaf0c92 - [clang-repl] Add an accessor to our underlying execution engine

Tom Stellard via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Apr 6 22:46:21 PDT 2022


Author: Vassil Vassilev
Date: 2022-04-06T22:20:02-07:00
New Revision: aaf0c921a54ac9f9d9bc0e74566f3153d25e0c00

URL: https://github.com/llvm/llvm-project/commit/aaf0c921a54ac9f9d9bc0e74566f3153d25e0c00
DIFF: https://github.com/llvm/llvm-project/commit/aaf0c921a54ac9f9d9bc0e74566f3153d25e0c00.diff

LOG: [clang-repl] Add an accessor to our underlying execution engine

This patch will allow better incremental adoption of these changes in downstream
cling and other users which want to experiment by customizing the execution
engine.

(cherry picked from commit 788e0f7f3e96a9d61c2412e452c4589e2693b79a)

Added: 
    

Modified: 
    clang/include/clang/Interpreter/Interpreter.h
    clang/lib/Interpreter/IncrementalExecutor.h
    clang/lib/Interpreter/Interpreter.cpp

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Interpreter/Interpreter.h b/clang/include/clang/Interpreter/Interpreter.h
index 721a649deb43b..f2fdb90f5ba48 100644
--- a/clang/include/clang/Interpreter/Interpreter.h
+++ b/clang/include/clang/Interpreter/Interpreter.h
@@ -26,6 +26,7 @@
 
 namespace llvm {
 namespace orc {
+class LLJIT;
 class ThreadSafeContext;
 }
 } // namespace llvm
@@ -56,6 +57,7 @@ class Interpreter {
   static llvm::Expected<std::unique_ptr<Interpreter>>
   create(std::unique_ptr<CompilerInstance> CI);
   const CompilerInstance *getCompilerInstance() const;
+  const llvm::orc::LLJIT *getExecutionEngine() const;
   llvm::Expected<PartialTranslationUnit &> Parse(llvm::StringRef Code);
   llvm::Error Execute(PartialTranslationUnit &T);
   llvm::Error ParseAndExecute(llvm::StringRef Code) {

diff  --git a/clang/lib/Interpreter/IncrementalExecutor.h b/clang/lib/Interpreter/IncrementalExecutor.h
index 24447994d5f1d..51b4d83d10b1c 100644
--- a/clang/lib/Interpreter/IncrementalExecutor.h
+++ b/clang/lib/Interpreter/IncrementalExecutor.h
@@ -45,6 +45,7 @@ class IncrementalExecutor {
   llvm::Error runCtors() const;
   llvm::Expected<llvm::JITTargetAddress>
   getSymbolAddress(llvm::StringRef Name, SymbolNameKind NameKind) const;
+  llvm::orc::LLJIT *getExecutionEngine() const { return Jit.get(); }
 };
 
 } // end namespace clang

diff  --git a/clang/lib/Interpreter/Interpreter.cpp b/clang/lib/Interpreter/Interpreter.cpp
index b2e7727be39a0..470c9c289a749 100644
--- a/clang/lib/Interpreter/Interpreter.cpp
+++ b/clang/lib/Interpreter/Interpreter.cpp
@@ -196,6 +196,12 @@ const CompilerInstance *Interpreter::getCompilerInstance() const {
   return IncrParser->getCI();
 }
 
+const llvm::orc::LLJIT *Interpreter::getExecutionEngine() const {
+  if (IncrExecutor)
+    return IncrExecutor->getExecutionEngine();
+  return nullptr;
+}
+
 llvm::Expected<PartialTranslationUnit &>
 Interpreter::Parse(llvm::StringRef Code) {
   return IncrParser->Parse(Code);


        


More information about the llvm-branch-commits mailing list