Skip to content

Conversation

kr-2003
Copy link
Contributor

@kr-2003 kr-2003 commented Aug 24, 2025

This is a refactoring PR. It sinks RemoteJITUtils into Interpreter and IncrementalExecutor classes.

Comment on lines +334 to +337
if (::OffloadArch.empty()) {
::OffloadArch = "sm_35";
}
CB.SetOffloadArch(OffloadArch);
CB.SetOffloadArch(::OffloadArch);
Copy link
Contributor

Choose a reason for hiding this comment

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

Are these changes relevant to the current PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes. if not done, it gives following error:

error: reference to 'OffloadArch' is ambiguous

Copy link
Contributor

Choose a reason for hiding this comment

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

Which compiler is this? Why it works upstream?

Copy link
Contributor

Choose a reason for hiding this comment

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

ping.

@vgvassilev vgvassilev requested a review from lhames August 25, 2025 12:07
Copy link

github-actions bot commented Aug 25, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

@kr-2003 kr-2003 requested a review from vgvassilev August 26, 2025 15:12
@kr-2003 kr-2003 requested a review from vgvassilev August 27, 2025 16:12
bool UseSharedMemory;

/// String representing the slab allocation size for memory management.
std::string SlabAllocateSizeString;
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be an unsigned int I think. All of these should have good default values.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually this has to be string. this is how it is handled:

static llvm::cl::opt<std::string> SlabAllocateSizeString(
    "slab-allocate",
    llvm::cl::desc("Allocate from a slab of the given size "
                   "(allowable suffixes: Kb, Mb, Gb. default = "
                   "Kb)"),
    llvm::cl::init(""), llvm::cl::cat(OOPCategory));

it has suffix

Copy link
Contributor

Choose a reason for hiding this comment

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

We can transform it before putting it in the config.

Comment on lines +334 to +337
if (::OffloadArch.empty()) {
::OffloadArch = "sm_35";
}
CB.SetOffloadArch(OffloadArch);
CB.SetOffloadArch(::OffloadArch);
Copy link
Contributor

Choose a reason for hiding this comment

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

Which compiler is this? Why it works upstream?

@kr-2003 kr-2003 changed the title [Clang-Repl] Add Lambda Support, PID Retrieval, and Dynamic liborc_rt Path in Clang-Repl [Clang-Repl] Sinking RemoteJITUtils into Interpreter class(Refactoring) Aug 31, 2025
@kr-2003 kr-2003 requested a review from vgvassilev August 31, 2025 18:18
@@ -15,6 +15,7 @@
#define LLVM_CLANG_INTERPRETER_INTERPRETER_H

#include "clang/AST/GlobalDecl.h"
#include "clang/Driver/ToolChain.h"
Copy link
Contributor

Choose a reason for hiding this comment

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

We can forward declare the driver::Toolchain and remove this include.

/// Indicates whether to use shared memory for communication.
bool UseSharedMemory;
/// String representing the slab allocation size for memory management.
std::string SlabAllocateSizeString;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
std::string SlabAllocateSizeString;
unsigned SlabAllocateSize = 1024;

std::string OOPExecutor;
std::string OOPExecutorConnect;
/// Indicates whether to use shared memory for communication.
bool UseSharedMemory;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
bool UseSharedMemory;
bool UseSharedMemory = true;

public:
struct OutOfProcessJITConfig {
/// Indicates whether out-of-process JIT execution is enabled.
bool IsOutOfProcess;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
bool IsOutOfProcess;
bool IsOutOfProcess = false;

Interpreter::outOfProcessJITBuilder(OutOfProcessJITConfig OutOfProcessConfig) {
std::unique_ptr<llvm::orc::ExecutorProcessControl> EPC;
pid_t childPid = -1;
if (OutOfProcessConfig.OOPExecutor != "") {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (OutOfProcessConfig.OOPExecutor != "") {
if (!OutOfProcessConfig.OOPExecutor.empty()) {

@@ -347,20 +348,118 @@ const char *const Runtimes = R"(
EXTERN_C void __clang_Interpreter_SetValueNoAlloc(void *This, void *OutVal, void *OpaqueType, ...);
)";

#ifndef _WIN32
Copy link
Contributor

Choose a reason for hiding this comment

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

Likewise.


std::unique_ptr<llvm::orc::LLJITBuilder> JB;

#ifndef _WIN32
Copy link
Contributor

Choose a reason for hiding this comment

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

Likewise.

Comment on lines +546 to +552
#ifndef _WIN32
pid_t Interpreter::getOutOfProcessExecutorPID() const {
if (IncrExecutor)
return IncrExecutor->getOutOfProcessChildPid();
return -1;
}
#endif
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
#ifndef _WIN32
pid_t Interpreter::getOutOfProcessExecutorPID() const {
if (IncrExecutor)
return IncrExecutor->getOutOfProcessChildPid();
return -1;
}
#endif
pid_t Interpreter::getOutOfProcessExecutorPID() const {
if (IncrExecutor)
return IncrExecutor->getOutOfProcessChildPid();
return -1;
}

@@ -512,7 +619,7 @@ Interpreter::createLLJITBuilder(
return std::move(*JB);
}

llvm::Error Interpreter::CreateExecutor() {
llvm::Error Interpreter::CreateExecutor(OutOfProcessJITConfig OOPConfig) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
llvm::Error Interpreter::CreateExecutor(OutOfProcessJITConfig OOPConfig) {
llvm::Error Interpreter::CreateExecutor(JITConfig Config = {}) {

@@ -535,9 +659,14 @@ llvm::Error Interpreter::CreateExecutor() {
llvm::Error Err = llvm::Error::success();
#ifdef __EMSCRIPTEN__
auto Executor = std::make_unique<WasmIncrementalExecutor>(*TSCtx);
#else
#ifndef _WIN32
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't need a special branch -- we just need to pass in empty JitConfig.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants