[clang] [Clang-Repl] Sinking RemoteJITUtils into Interpreter class(Refactoring) (PR #155140)
Vassil Vassilev via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 2 00:02:44 PDT 2025
================
@@ -115,31 +116,60 @@ class Interpreter {
/// An optional compiler instance for CUDA offloading
std::unique_ptr<CompilerInstance> DeviceCI;
+public:
+ struct OutOfProcessJITConfig {
+ /// Indicates whether out-of-process JIT execution is enabled.
+ bool IsOutOfProcess;
+ /// Path to the out-of-process JIT executor.
+ std::string OOPExecutor;
+ std::string OOPExecutorConnect;
+ /// Indicates whether to use shared memory for communication.
+ bool UseSharedMemory;
+ /// String representing the slab allocation size for memory management.
+ std::string SlabAllocateSizeString;
+ /// Path to the ORC runtime library.
+ std::string OrcRuntimePath;
+
+ OutOfProcessJITConfig()
+ : IsOutOfProcess(false), OOPExecutor(""), OOPExecutorConnect(""),
+ UseSharedMemory(false), SlabAllocateSizeString(""),
+ OrcRuntimePath("") {}
+ };
+
protected:
// Derived classes can use an extended interface of the Interpreter.
Interpreter(std::unique_ptr<CompilerInstance> Instance, llvm::Error &Err,
std::unique_ptr<llvm::orc::LLJITBuilder> JITBuilder = nullptr,
- std::unique_ptr<clang::ASTConsumer> Consumer = nullptr);
+ std::unique_ptr<clang::ASTConsumer> Consumer = nullptr,
+ OutOfProcessJITConfig OOPConfig = OutOfProcessJITConfig());
// Create the internal IncrementalExecutor, or re-create it after calling
// ResetExecutor().
- llvm::Error CreateExecutor();
+ llvm::Error
+ CreateExecutor(OutOfProcessJITConfig OOPConfig = OutOfProcessJITConfig());
// Delete the internal IncrementalExecutor. This causes a hard shutdown of the
// JIT engine. In particular, it doesn't run cleanup or destructors.
void ResetExecutor();
public:
virtual ~Interpreter();
- static llvm::Expected<std::unique_ptr<Interpreter>>
- create(std::unique_ptr<CompilerInstance> CI,
- std::unique_ptr<llvm::orc::LLJITBuilder> JITBuilder = nullptr);
+ static llvm::Expected<std::unique_ptr<Interpreter>> create(
+ std::unique_ptr<CompilerInstance> CI,
+ std::optional<OutOfProcessJITConfig> OutOfProcessConfig = std::nullopt);
static llvm::Expected<std::unique_ptr<Interpreter>>
createWithCUDA(std::unique_ptr<CompilerInstance> CI,
std::unique_ptr<CompilerInstance> DCI);
static llvm::Expected<std::unique_ptr<llvm::orc::LLJITBuilder>>
createLLJITBuilder(std::unique_ptr<llvm::orc::ExecutorProcessControl> EPC,
llvm::StringRef OrcRuntimePath);
+#ifndef _WIN32
+ static llvm::Expected<
+ std::pair<std::unique_ptr<llvm::orc::LLJITBuilder>, pid_t>>
+ outOfProcessJITBuilder(OutOfProcessJITConfig OutOfProcessConfig);
+ static llvm::Expected<std::string>
+ getOrcRuntimePath(const driver::ToolChain &TC);
+#endif
----------------
vgvassilev wrote:
```suggestion
static llvm::Expected<
std::pair<std::unique_ptr<llvm::orc::LLJITBuilder>, pid_t>>
outOfProcessJITBuilder(OutOfProcessJITConfig OutOfProcessConfig);
static llvm::Expected<std::string>
getOrcRuntimePath(const driver::ToolChain &TC);
```
We should drop these checks and return `llvm::Error` if the target triple is Windows.
https://github.com/llvm/llvm-project/pull/155140
More information about the cfe-commits
mailing list