2323#include " llvm/ExecutionEngine/Orc/ExecutorProcessControl.h"
2424#include " llvm/ExecutionEngine/Orc/Shared/ExecutorAddress.h"
2525#include " llvm/Support/Error.h"
26+ #include < cstdint>
2627#include < memory>
2728#include < vector>
2829
@@ -36,6 +37,10 @@ class ThreadSafeContext;
3637
3738namespace clang {
3839
40+ namespace driver {
41+ class ToolChain ;
42+ } // namespace driver
43+
3944class CompilerInstance ;
4045class CXXRecordDecl ;
4146class Decl ;
@@ -115,15 +120,38 @@ class Interpreter {
115120 // / An optional compiler instance for CUDA offloading
116121 std::unique_ptr<CompilerInstance> DeviceCI;
117122
123+ public:
124+ struct JITConfig {
125+ // / Indicates whether out-of-process JIT execution is enabled.
126+ bool IsOutOfProcess = false ;
127+ // / Path to the out-of-process JIT executor.
128+ std::string OOPExecutor = " " ;
129+ std::string OOPExecutorConnect = " " ;
130+ // / Indicates whether to use shared memory for communication.
131+ bool UseSharedMemory = false ;
132+ // / Representing the slab allocation size for memory management in kb.
133+ unsigned SlabAllocateSize = 0 ;
134+ // / Path to the ORC runtime library.
135+ std::string OrcRuntimePath = " " ;
136+ // / PID of the out-of-process JIT executor.
137+ uint32_t ExecutorPID = 0 ;
138+
139+ JITConfig ()
140+ : IsOutOfProcess(false ), OOPExecutor(" " ), OOPExecutorConnect(" " ),
141+ UseSharedMemory (false ), SlabAllocateSize(0 ), OrcRuntimePath(" " ),
142+ ExecutorPID(0 ) {}
143+ };
144+
118145protected:
119146 // Derived classes can use an extended interface of the Interpreter.
120147 Interpreter (std::unique_ptr<CompilerInstance> Instance, llvm::Error &Err,
121148 std::unique_ptr<llvm::orc::LLJITBuilder> JITBuilder = nullptr ,
122- std::unique_ptr<clang::ASTConsumer> Consumer = nullptr );
149+ std::unique_ptr<clang::ASTConsumer> Consumer = nullptr ,
150+ JITConfig Config = JITConfig());
123151
124152 // Create the internal IncrementalExecutor, or re-create it after calling
125153 // ResetExecutor().
126- llvm::Error CreateExecutor ();
154+ llvm::Error CreateExecutor (JITConfig Config = JITConfig() );
127155
128156 // Delete the internal IncrementalExecutor. This causes a hard shutdown of the
129157 // JIT engine. In particular, it doesn't run cleanup or destructors.
@@ -132,14 +160,19 @@ class Interpreter {
132160public:
133161 virtual ~Interpreter ();
134162 static llvm::Expected<std::unique_ptr<Interpreter>>
135- create (std::unique_ptr<CompilerInstance> CI,
136- std::unique_ptr<llvm::orc::LLJITBuilder> JITBuilder = nullptr );
163+ create (std::unique_ptr<CompilerInstance> CI, JITConfig Config = {});
137164 static llvm::Expected<std::unique_ptr<Interpreter>>
138165 createWithCUDA (std::unique_ptr<CompilerInstance> CI,
139166 std::unique_ptr<CompilerInstance> DCI);
140167 static llvm::Expected<std::unique_ptr<llvm::orc::LLJITBuilder>>
141168 createLLJITBuilder (std::unique_ptr<llvm::orc::ExecutorProcessControl> EPC,
142169 llvm::StringRef OrcRuntimePath);
170+ static llvm::Expected<
171+ std::pair<std::unique_ptr<llvm::orc::LLJITBuilder>, uint32_t >>
172+ outOfProcessJITBuilder (JITConfig Config);
173+ static llvm::Expected<std::string>
174+ getOrcRuntimePath (const driver::ToolChain &TC);
175+
143176 const ASTContext &getASTContext () const ;
144177 ASTContext &getASTContext ();
145178 const CompilerInstance *getCompilerInstance () const ;
@@ -170,6 +203,8 @@ class Interpreter {
170203 llvm::Expected<llvm::orc::ExecutorAddr>
171204 getSymbolAddressFromLinkerName (llvm::StringRef LinkerName) const ;
172205
206+ uint32_t getOutOfProcessExecutorPID () const ;
207+
173208private:
174209 size_t getEffectivePTUSize () const ;
175210 void markUserCodeStart ();
0 commit comments