-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[clang-repl] Sink RemoteJITUtils into Interpreter class (NFC) #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
Changes from 23 commits
79849c3
825f005
52b0902
3b4fcad
e174e98
b744a9f
0c6c995
2cf71ed
7c29008
41f8e54
4f1d203
a6a4369
63de886
c24e84e
b114bb8
850b953
956f393
14e5afd
65afbff
7dc6590
095a63b
2b6dc6c
7ad10a6
6a58d5f
f1b9135
dd73052
e90df55
521be31
baaff1e
44cde65
fc1f0da
c49ec55
a6a05ea
f2ca64e
0c99b67
51d6657
a71c546
37a9f3d
2cdb210
129a62b
c856255
3a15ddf
54a0dba
98c59b4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,15 +25,25 @@ | |
| #include "llvm/ExecutionEngine/Orc/LLJIT.h" | ||
| #include "llvm/LineEditor/LineEditor.h" | ||
| #include "llvm/Support/CommandLine.h" | ||
| #include "llvm/Support/FileSystem.h" | ||
| #include "llvm/Support/ManagedStatic.h" // llvm_shutdown | ||
| #include "llvm/Support/Path.h" | ||
| #include "llvm/Support/Signals.h" | ||
| #include "llvm/Support/TargetSelect.h" | ||
| #include "llvm/Support/VirtualFileSystem.h" | ||
| #include "llvm/Support/raw_ostream.h" | ||
| #include "llvm/TargetParser/Host.h" | ||
| #include "llvm/TargetParser/Triple.h" | ||
| #include <optional> | ||
|
|
||
| #include <iostream> | ||
kr-2003 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| #include <string> | ||
| #include <vector> | ||
|
|
||
| #include "llvm/ExecutionEngine/Orc/Debugging/DebuggerSupport.h" | ||
|
|
||
| using namespace clang; | ||
|
|
||
| // Disable LSan for this test. | ||
| // FIXME: Re-enable once we can assume GCC 13.2 or higher. | ||
| // https://llvm.org/github.com/llvm/llvm-project/issues/67586. | ||
|
|
@@ -81,7 +91,8 @@ static llvm::cl::opt<bool> OptHostSupportsJit("host-supports-jit", | |
| static llvm::cl::list<std::string> OptInputs(llvm::cl::Positional, | ||
| llvm::cl::desc("[code to run]")); | ||
|
|
||
| static llvm::Error sanitizeOopArguments(const char *ArgV0) { | ||
| static llvm::Error sanitizeOopArguments(const char *ArgV0, | ||
| std::string _OrcRuntimePath) { | ||
| // Only one of -oop-executor and -oop-executor-connect can be used. | ||
| if (!!OOPExecutor.getNumOccurrences() && | ||
| !!OOPExecutorConnect.getNumOccurrences()) | ||
|
|
@@ -117,21 +128,11 @@ static llvm::Error sanitizeOopArguments(const char *ArgV0) { | |
| // Out-of-process executors require the ORC runtime. | ||
| if (OrcRuntimePath.empty() && (OOPExecutor.getNumOccurrences() || | ||
| OOPExecutorConnect.getNumOccurrences())) { | ||
| llvm::SmallString<256> BasePath(llvm::sys::fs::getMainExecutable( | ||
| ArgV0, reinterpret_cast<void *>(&sanitizeOopArguments))); | ||
| llvm::sys::path::remove_filename(BasePath); // Remove clang-repl filename. | ||
| llvm::sys::path::remove_filename(BasePath); // Remove ./bin directory. | ||
| llvm::sys::path::append(BasePath, CLANG_INSTALL_LIBDIR_BASENAME, "clang", | ||
| CLANG_VERSION_MAJOR_STRING); | ||
| if (SystemTriple.isOSBinFormatELF()) | ||
| OrcRuntimePath = | ||
| BasePath.str().str() + "/lib/x86_64-unknown-linux-gnu/liborc_rt.a"; | ||
| else if (SystemTriple.isOSBinFormatMachO()) | ||
| OrcRuntimePath = BasePath.str().str() + "/lib/darwin/liborc_rt_osx.a"; | ||
| else | ||
| if(!llvm::sys::fs::exists(_OrcRuntimePath)) | ||
kr-2003 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| return llvm::make_error<llvm::StringError>( | ||
| "Out-of-process execution is not supported on non-unix platforms", | ||
| "The ORC runtime is required for out-of-process execution", | ||
| llvm::inconvertibleErrorCode()); | ||
| OrcRuntimePath = _OrcRuntimePath; | ||
| } | ||
|
|
||
| // If -oop-executor was used but no value was specified then use a sensible | ||
|
|
@@ -186,7 +187,7 @@ struct ReplListCompleter { | |
| clang::Interpreter &MainInterp; | ||
| ReplListCompleter(clang::IncrementalCompilerBuilder &CB, | ||
| clang::Interpreter &Interp) | ||
| : CB(CB), MainInterp(Interp){}; | ||
| : CB(CB), MainInterp(Interp) {}; | ||
|
|
||
| std::vector<llvm::LineEditor::Completion> operator()(llvm::StringRef Buffer, | ||
| size_t Pos) const; | ||
|
|
@@ -275,15 +276,26 @@ int main(int argc, const char **argv) { | |
| if (!CudaPath.empty()) | ||
| CB.SetCudaSDK(CudaPath); | ||
|
|
||
| if (OffloadArch.empty()) { | ||
| OffloadArch = "sm_35"; | ||
| if (::OffloadArch.empty()) { | ||
| ::OffloadArch = "sm_35"; | ||
| } | ||
| CB.SetOffloadArch(OffloadArch); | ||
| CB.SetOffloadArch(::OffloadArch); | ||
|
||
|
|
||
| DeviceCI = ExitOnErr(CB.CreateCudaDevice()); | ||
| } | ||
|
|
||
| ExitOnErr(sanitizeOopArguments(argv[0])); | ||
| std::string _OrcRuntimePath; | ||
|
|
||
| // FIXME: Investigate if we could use runToolOnCodeWithArgs from tooling. It | ||
| // can replace the boilerplate code for creation of the compiler instance. | ||
| std::unique_ptr<clang::CompilerInstance> CI; | ||
| if (CudaEnabled) { | ||
| CI = ExitOnErr(CB.CreateCudaHost()); | ||
| } else { | ||
| CI = ExitOnErr(CB.CreateCpp(&_OrcRuntimePath)); | ||
| } | ||
|
|
||
| ExitOnErr(sanitizeOopArguments(argv[0], _OrcRuntimePath)); | ||
|
|
||
| std::unique_ptr<llvm::orc::ExecutorProcessControl> EPC; | ||
| if (OOPExecutor.getNumOccurrences()) { | ||
|
|
@@ -302,15 +314,6 @@ int main(int argc, const char **argv) { | |
| clang::Interpreter::createLLJITBuilder(std::move(EPC), OrcRuntimePath)); | ||
| } | ||
|
|
||
| // FIXME: Investigate if we could use runToolOnCodeWithArgs from tooling. It | ||
| // can replace the boilerplate code for creation of the compiler instance. | ||
| std::unique_ptr<clang::CompilerInstance> CI; | ||
| if (CudaEnabled) { | ||
| CI = ExitOnErr(CB.CreateCudaHost()); | ||
| } else { | ||
| CI = ExitOnErr(CB.CreateCpp()); | ||
| } | ||
|
|
||
| // Set an error handler, so that any LLVM backend diagnostics go through our | ||
| // error handler. | ||
| llvm::install_fatal_error_handler(LLVMErrorHandler, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.