Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion include/CppInterOp/CppInterOp.h
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ CPPINTEROP_API void GetOperator(TCppScope_t scope, Operator op,
///\returns nullptr on failure.
CPPINTEROP_API TInterp_t
CreateInterpreter(const std::vector<const char*>& Args = {},
const std::vector<const char*>& GpuArgs = {});
const std::vector<const char*>& GpuArgs = {}, bool is_out_of_process = false);

/// Deletes an instance of an interpreter.
///\param[in] I - the interpreter to be deleted, if nullptr, deletes the last.
Expand Down
35 changes: 33 additions & 2 deletions lib/CppInterOp/Compatibility.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,20 @@ inline void codeComplete(std::vector<std::string>& Results,

#include "llvm/Support/Error.h"

#include "clang/Interpreter/RemoteJITUtils.h"
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: 'clang/Interpreter/RemoteJITUtils.h' file not found [clang-diagnostic-error]

#include "clang/Interpreter/RemoteJITUtils.h"
         ^

#include "clang/Basic/Version.h"
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: #includes are not sorted properly [llvm-include-order]

Suggested change
#include "clang/Basic/Version.h"
#include "clang/Basic/Version.h"
#include "clang/Interpreter/RemoteJITUtils.h"

#include "llvm/TargetParser/Host.h"

#include "llvm/ExecutionEngine/Orc/Debugging/DebuggerSupport.h"

#include "llvm/Support/CommandLine.h"

Copy link
Contributor

Choose a reason for hiding this comment

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

warning: included header CommandLine.h is not used directly [misc-include-cleaner]

Suggested change

static llvm::ExitOnError ExitOnError;
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: variable 'ExitOnError' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables]

static llvm::ExitOnError ExitOnError;
                         ^


namespace compat {

inline std::unique_ptr<clang::Interpreter>
createClangInterpreter(std::vector<const char*>& args) {
createClangInterpreter(std::vector<const char*>& args, bool is_out_of_process) {
auto has_arg = [](const char* x, llvm::StringRef match = "cuda") {
llvm::StringRef Arg = x;
Arg = Arg.trim().ltrim('-');
Expand Down Expand Up @@ -241,10 +251,31 @@ createClangInterpreter(std::vector<const char*>& args) {
(*ciOrErr)->LoadRequestedPlugins();
if (CudaEnabled)
DeviceCI->LoadRequestedPlugins();

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

if(is_out_of_process) {
std::string OOPExecutor = "/Users/abhinavkumar/Desktop/Coding/CERN_HSF_COMPILER_RESEARCH/llvm-project-test/build/bin/llvm-jitlink-executor";
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: no header providing "std::string" is directly included [misc-include-cleaner]

lib/CppInterOp/Compatibility.h:10:

+ #include <string>

bool UseSharedMemory = false;
std::string SlabAllocateSizeString = "";
std::unique_ptr<llvm::orc::ExecutorProcessControl> EPC;
EPC = ExitOnError(
launchExecutor(OOPExecutor, UseSharedMemory, SlabAllocateSizeString));


std::string OrcRuntimePath = "/Users/abhinavkumar/Desktop/Coding/CERN_HSF_COMPILER_RESEARCH/llvm-project-test/build/lib/clang/20/lib/darwin/liborc_rt_osx.a";
if (EPC) {

CB.SetTargetTriple(EPC->getTargetTriple().getTriple());
JB = ExitOnError(
clang::Interpreter::createLLJITBuilder(std::move(EPC), OrcRuntimePath));
}
}

auto innerOrErr =
CudaEnabled ? clang::Interpreter::createWithCUDA(std::move(*ciOrErr),
std::move(DeviceCI))
: clang::Interpreter::create(std::move(*ciOrErr));
: clang::Interpreter::create(std::move(*ciOrErr), std::move(JB));

if (!innerOrErr) {
llvm::logAllUnhandledErrors(innerOrErr.takeError(), llvm::errs(),
Expand Down
6 changes: 3 additions & 3 deletions lib/CppInterOp/CppInterOp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2911,11 +2911,11 @@ static std::string MakeResourcesPath() {
} // namespace

TInterp_t CreateInterpreter(const std::vector<const char*>& Args /*={}*/,
const std::vector<const char*>& GpuArgs /*={}*/) {
const std::vector<const char*>& GpuArgs /*={}*/, bool is_out_of_process) {
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: 'MakeResourcesPath' is a static definition in anonymous namespace; static is redundant here [readability-static-definition-in-anonymous-namespace]

Suggested change
const std::vector<const char*>& GpuArgs /*={}*/, bool is_out_of_process) {
std::string MakeResourcesPath() {

std::string MainExecutableName = sys::fs::getMainExecutable(nullptr, nullptr);
std::string ResourceDir = MakeResourcesPath();
std::vector<const char*> ClingArgv = {"-resource-dir", ResourceDir.c_str(),
"-std=c++14"};
"-std=c++14", "-gdwarf-4", "-O0"};
ClingArgv.insert(ClingArgv.begin(), MainExecutableName.c_str());
#ifdef _WIN32
// FIXME : Workaround Sema::PushDeclContext assert on windows
Expand Down Expand Up @@ -2955,7 +2955,7 @@ TInterp_t CreateInterpreter(const std::vector<const char*>& Args /*={}*/,
auto I = new compat::Interpreter(ClingArgv.size(), &ClingArgv[0]);
#else
auto Interp = compat::Interpreter::create(static_cast<int>(ClingArgv.size()),
ClingArgv.data());
ClingArgv.data(), nullptr, {}, nullptr, true, is_out_of_process);
if (!Interp)
return nullptr;
auto* I = Interp.release();
Expand Down
4 changes: 2 additions & 2 deletions lib/CppInterOp/CppInterOpInterpreter.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,15 +150,15 @@ class Interpreter {
create(int argc, const char* const* argv, const char* llvmdir = nullptr,
const std::vector<std::shared_ptr<clang::ModuleFileExtension>>&
moduleExtensions = {},
void* extraLibHandle = nullptr, bool noRuntime = true) {
void* extraLibHandle = nullptr, bool noRuntime = true, bool is_out_of_process = false) {
// Initialize all targets (required for device offloading)
llvm::InitializeAllTargetInfos();
llvm::InitializeAllTargets();
llvm::InitializeAllTargetMCs();
llvm::InitializeAllAsmPrinters();

std::vector<const char*> vargs(argv + 1, argv + argc);
auto CI = compat::createClangInterpreter(vargs);
auto CI = compat::createClangInterpreter(vargs, is_out_of_process);
if (!CI) {
llvm::errs() << "Interpreter creation failed\n";
return nullptr;
Expand Down
Loading