Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
79849c3
pipes for redirection in oop jit
Jul 1, 2025
825f005
Merge branch 'main' into redirection
kr-2003 Jul 29, 2025
52b0902
refactoring
Jul 29, 2025
3b4fcad
refactoring
Jul 29, 2025
e174e98
commenting & refactoring
Jul 29, 2025
b744a9f
compiler-rt conditional addition
Aug 1, 2025
0c6c995
Merge branch 'main' into redirection
kr-2003 Aug 1, 2025
2cf71ed
removed compiler-rt dep
Aug 1, 2025
7c29008
Merge branch 'redirection' of https://github.com/kr-2003/llvm-project…
Aug 1, 2025
41f8e54
separate file for oop tests
Aug 1, 2025
4f1d203
separate file for oop tests
Aug 1, 2025
a6a4369
separate file for oop tests
Aug 1, 2025
63de886
test file rename
Aug 1, 2025
c24e84e
test file rename
Aug 1, 2025
b114bb8
test file rename
Aug 1, 2025
850b953
resolving comments & InterpreterRemoteTest
Aug 3, 2025
956f393
resolving comments
Aug 3, 2025
14e5afd
resolving comments
Aug 4, 2025
65afbff
Custom lambda in launchExecutor and pid retrieval
Aug 5, 2025
7dc6590
Merge branch 'main' of https://github.com/llvm/llvm-project into redi…
Aug 20, 2025
095a63b
Dynamic path resolution
Aug 24, 2025
2b6dc6c
Dynamic path resolution using IncrementalCB
Aug 25, 2025
7ad10a6
Dynamic path resolution using IncrementalCB
Aug 25, 2025
6a58d5f
Addressing reviews
Aug 26, 2025
f1b9135
Sinking JitBuilder into Interpreter
Aug 27, 2025
dd73052
RemoteJITUtils shifted to IncrementalExecutor
Aug 31, 2025
e90df55
RemoteJITUtils shifted to IncrementalExecutor
Aug 31, 2025
521be31
Removed custom fork in launchExecutor lambda
Aug 31, 2025
baaff1e
Merge branch 'main' into redirection
kr-2003 Aug 31, 2025
44cde65
refactoring changes
Aug 31, 2025
fc1f0da
Merge branch 'redirection' of https://github.com/kr-2003/llvm-project…
Aug 31, 2025
c49ec55
Refactoring
Aug 31, 2025
a6a05ea
Deleted RemoteJITUtils.h & .cpp
Aug 31, 2025
f2ca64e
Refactoring
Aug 31, 2025
0c99b67
Refactoring
Aug 31, 2025
51d6657
Refactoring
Aug 31, 2025
a71c546
formatting
Aug 31, 2025
37a9f3d
formatting
Aug 31, 2025
2cdb210
Addressing reviews
Sep 5, 2025
129a62b
Addressing reviews
Sep 5, 2025
c856255
Addressing reviews
Sep 5, 2025
3a15ddf
Fix connectTCPSocket on non-unix
Sep 6, 2025
54a0dba
Fixing ambiguity and resolving comments
Sep 7, 2025
98c59b4
Fixing ambiguity and resolving comments
Sep 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 39 additions & 4 deletions clang/include/clang/Interpreter/Interpreter.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "llvm/ExecutionEngine/Orc/ExecutorProcessControl.h"
#include "llvm/ExecutionEngine/Orc/Shared/ExecutorAddress.h"
#include "llvm/Support/Error.h"
#include <cstdint>
#include <memory>
#include <vector>

Expand All @@ -36,6 +37,10 @@ class ThreadSafeContext;

namespace clang {

namespace driver {
class ToolChain;
} // namespace driver

class CompilerInstance;
class CXXRecordDecl;
class Decl;
Expand Down Expand Up @@ -115,15 +120,38 @@ class Interpreter {
/// An optional compiler instance for CUDA offloading
std::unique_ptr<CompilerInstance> DeviceCI;

public:
struct JITConfig {
/// Indicates whether out-of-process JIT execution is enabled.
bool IsOutOfProcess = false;
/// Path to the out-of-process JIT executor.
std::string OOPExecutor = "";
std::string OOPExecutorConnect = "";
/// Indicates whether to use shared memory for communication.
bool UseSharedMemory = false;
/// Representing the slab allocation size for memory management in kb.
unsigned SlabAllocateSize = 0;
/// Path to the ORC runtime library.
std::string OrcRuntimePath = "";
/// PID of the out-of-process JIT executor.
uint32_t ExecutorPID = 0;

JITConfig()
: IsOutOfProcess(false), OOPExecutor(""), OOPExecutorConnect(""),
UseSharedMemory(false), SlabAllocateSize(0), OrcRuntimePath(""),
ExecutorPID(0) {}
};

Comment on lines +123 to +144
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From discussion with @vgvassilev it sounds like the motivation here was to defer creation of the LLJITBuilder until you can ask the driver for the runtime path?

This solves that problem, but eliminates the ability to configure the builder.

What if you added a new member and callback along the lines of:

  std::optional<std::string> OrcRuntimePath;
  llvm::unique_function<LLJITBuilder(&JITConfig)> MakeJITBuilder = makeDefaultJITBuilder;

then in the setup path you'd have something like:

  if (!Cfg.OrcRuntimePath) {
    if (OrcRTPath = getOrcRuntimePath(TC))
      CfgOrcRuntimePath = std::move(*OrcRTPath);
    else
      return OrcRTPath.takeError();
  }
  auto JITBuilder = MakeJITBuilder(Cfg);
  if (auto JOrErr = JITBuilder.create())
    J = std::move(*JOrErr);
  else
    return JOrErr.takeError();
  ...

The extra indirection gives you the opportunity to ask the driver for the path (if one isn't provided) while still giving the client the opportunity to configure the LLJITBuilder.

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,
JITConfig Config = JITConfig());

// Create the internal IncrementalExecutor, or re-create it after calling
// ResetExecutor().
llvm::Error CreateExecutor();
llvm::Error CreateExecutor(JITConfig Config = JITConfig());

// Delete the internal IncrementalExecutor. This causes a hard shutdown of the
// JIT engine. In particular, it doesn't run cleanup or destructors.
Expand All @@ -132,14 +160,19 @@ class Interpreter {
public:
virtual ~Interpreter();
static llvm::Expected<std::unique_ptr<Interpreter>>
create(std::unique_ptr<CompilerInstance> CI,
std::unique_ptr<llvm::orc::LLJITBuilder> JITBuilder = nullptr);
create(std::unique_ptr<CompilerInstance> CI, JITConfig Config = {});
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);
static llvm::Expected<
std::pair<std::unique_ptr<llvm::orc::LLJITBuilder>, uint32_t>>
outOfProcessJITBuilder(JITConfig Config);
static llvm::Expected<std::string>
getOrcRuntimePath(const driver::ToolChain &TC);

const ASTContext &getASTContext() const;
ASTContext &getASTContext();
const CompilerInstance *getCompilerInstance() const;
Expand Down Expand Up @@ -170,6 +203,8 @@ class Interpreter {
llvm::Expected<llvm::orc::ExecutorAddr>
getSymbolAddressFromLinkerName(llvm::StringRef LinkerName) const;

uint32_t getOutOfProcessExecutorPID() const;

private:
size_t getEffectivePTUSize() const;
void markUserCodeStart();
Expand Down
38 changes: 0 additions & 38 deletions clang/include/clang/Interpreter/RemoteJITUtils.h

This file was deleted.

1 change: 0 additions & 1 deletion clang/lib/Interpreter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ add_clang_library(clangInterpreter
Interpreter.cpp
InterpreterValuePrinter.cpp
InterpreterUtils.cpp
RemoteJITUtils.cpp
Value.cpp
InterpreterValuePrinter.cpp
${WASM_SRC}
Expand Down
Loading