23
23
#include " llvm/ExecutionEngine/Orc/ExecutorProcessControl.h"
24
24
#include " llvm/ExecutionEngine/Orc/Shared/ExecutorAddress.h"
25
25
#include " llvm/Support/Error.h"
26
+ #include < cstdint>
26
27
#include < memory>
27
28
#include < vector>
28
29
@@ -36,6 +37,10 @@ class ThreadSafeContext;
36
37
37
38
namespace clang {
38
39
40
+ namespace driver {
41
+ class ToolChain ;
42
+ } // namespace driver
43
+
39
44
class CompilerInstance ;
40
45
class CXXRecordDecl ;
41
46
class Decl ;
@@ -115,15 +120,38 @@ class Interpreter {
115
120
// / An optional compiler instance for CUDA offloading
116
121
std::unique_ptr<CompilerInstance> DeviceCI;
117
122
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
+
118
145
protected:
119
146
// Derived classes can use an extended interface of the Interpreter.
120
147
Interpreter (std::unique_ptr<CompilerInstance> Instance, llvm::Error &Err,
121
148
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());
123
151
124
152
// Create the internal IncrementalExecutor, or re-create it after calling
125
153
// ResetExecutor().
126
- llvm::Error CreateExecutor ();
154
+ llvm::Error CreateExecutor (JITConfig Config = JITConfig() );
127
155
128
156
// Delete the internal IncrementalExecutor. This causes a hard shutdown of the
129
157
// JIT engine. In particular, it doesn't run cleanup or destructors.
@@ -132,14 +160,19 @@ class Interpreter {
132
160
public:
133
161
virtual ~Interpreter ();
134
162
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 = {});
137
164
static llvm::Expected<std::unique_ptr<Interpreter>>
138
165
createWithCUDA (std::unique_ptr<CompilerInstance> CI,
139
166
std::unique_ptr<CompilerInstance> DCI);
140
167
static llvm::Expected<std::unique_ptr<llvm::orc::LLJITBuilder>>
141
168
createLLJITBuilder (std::unique_ptr<llvm::orc::ExecutorProcessControl> EPC,
142
169
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
+
143
176
const ASTContext &getASTContext () const ;
144
177
ASTContext &getASTContext ();
145
178
const CompilerInstance *getCompilerInstance () const ;
@@ -170,6 +203,8 @@ class Interpreter {
170
203
llvm::Expected<llvm::orc::ExecutorAddr>
171
204
getSymbolAddressFromLinkerName (llvm::StringRef LinkerName) const ;
172
205
206
+ uint32_t getOutOfProcessExecutorPID () const ;
207
+
173
208
private:
174
209
size_t getEffectivePTUSize () const ;
175
210
void markUserCodeStart ();
0 commit comments