-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[Clang-Repl] Sinking RemoteJITUtils into Interpreter class(Refactoring) #155140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…into redirection
if (::OffloadArch.empty()) { | ||
::OffloadArch = "sm_35"; | ||
} | ||
CB.SetOffloadArch(OffloadArch); | ||
CB.SetOffloadArch(::OffloadArch); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ping.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(base) llvm-project-test % clang --version
Homebrew clang version 20.1.6
Target: arm64-apple-darwin24.5.0
Thread model: posix
InstalledDir: /opt/homebrew/Cellar/llvm/20.1.6/bin
Configuration file: /opt/homebrew/etc/clang/arm64-apple-darwin24.cfg'
✅ With the latest revision this PR passed the C/C++ code formatter. |
bool UseSharedMemory; | ||
|
||
/// String representing the slab allocation size for memory management. | ||
std::string SlabAllocateSizeString; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
if (::OffloadArch.empty()) { | ||
::OffloadArch = "sm_35"; | ||
} | ||
CB.SetOffloadArch(OffloadArch); | ||
CB.SetOffloadArch(::OffloadArch); |
There was a problem hiding this comment.
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?
/// Indicates whether to use shared memory for communication. | ||
bool UseSharedMemory; | ||
/// String representing the slab allocation size for memory management. | ||
std::string SlabAllocateSizeString; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
std::string SlabAllocateSizeString; | |
unsigned SlabAllocateSize = 1024; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still believe that having this as string should not be changed. otherwise, we will have more code for conversion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code for conversion will be exactly the same. It's location will be different. I do not see a reason for the user API to take strings when it can take the right types constructed programmatically.
std::string OOPExecutor; | ||
std::string OOPExecutorConnect; | ||
/// Indicates whether to use shared memory for communication. | ||
bool UseSharedMemory; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bool UseSharedMemory; | |
bool UseSharedMemory = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
already initialised in the constructor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's probably clearer to initialize it here too.
public: | ||
struct OutOfProcessJITConfig { | ||
/// Indicates whether out-of-process JIT execution is enabled. | ||
bool IsOutOfProcess; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bool IsOutOfProcess; | |
bool IsOutOfProcess = false; |
@@ -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 |
There was a problem hiding this comment.
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
.
DiagnosticsEngine &Diags = CI->getDiagnostics(); | ||
std::string BinaryName = llvm::sys::fs::getMainExecutable(nullptr, nullptr); | ||
driver::Driver Driver(BinaryName, Triple.str(), Diags); | ||
std::vector<const char *> Args = {"clang", "--version"}; | ||
std::unique_ptr<clang::driver::Compilation> C( | ||
Driver.BuildCompilation(Args)); | ||
if (!C) { | ||
return llvm::make_error<llvm::StringError>( | ||
"Failed to create driver compilation for out-of-process JIT", | ||
std::error_code()); | ||
} | ||
if (Config.OrcRuntimePath == "") { | ||
const clang::driver::ToolChain &TC = C->getDefaultToolChain(); | ||
|
||
auto OrcRuntimePathOrErr = getOrcRuntimePath(TC); | ||
if (!OrcRuntimePathOrErr) { | ||
return OrcRuntimePathOrErr.takeError(); | ||
} | ||
|
||
Config.OrcRuntimePath = *OrcRuntimePathOrErr; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to happen on the existing compiler instance that we create and not on a fake one clang --version
.
@@ -521,6 +618,23 @@ llvm::Error Interpreter::CreateExecutor() { | |||
return llvm::make_error<llvm::StringError>("Operation failed. " | |||
"No code generator available", | |||
std::error_code()); | |||
#ifndef _WIN32 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We must check the target triple, not an ifdef because we can be cross compiling.
This is a refactoring PR. It sinks RemoteJITUtils into Interpreter and IncrementalExecutor classes.