Skip to content

Commit

Permalink
[lli] Pass command line arguments in to the orc-lazy JIT.
Browse files Browse the repository at this point in the history
This brings the LLI orc-lazy JIT's behavior more closely in-line with LLI's
mcjit bahavior.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285413 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
lhames committed Oct 28, 2016
1 parent fe1e3ec commit 95d4f2c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
9 changes: 6 additions & 3 deletions tools/lli/OrcLazyJIT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ static PtrTy fromTargetAddress(JITTargetAddress Addr) {
return reinterpret_cast<PtrTy>(static_cast<uintptr_t>(Addr));
}

int llvm::runOrcLazyJIT(std::vector<std::unique_ptr<Module>> Ms, int ArgC,
char* ArgV[]) {
int llvm::runOrcLazyJIT(std::vector<std::unique_ptr<Module>> Ms,
const std::vector<std::string> &Args) {
// Add the program's symbols into the JIT's search space.
if (sys::DynamicLibrary::LoadLibraryPermanently(nullptr)) {
errs() << "Error loading program symbols.\n";
Expand Down Expand Up @@ -152,7 +152,10 @@ int llvm::runOrcLazyJIT(std::vector<std::unique_ptr<Module>> Ms, int ArgC,
}

typedef int (*MainFnPtr)(int, char*[]);
std::vector<const char *> ArgV;
for (auto &Arg : Args)
ArgV.push_back(Arg.c_str());
auto Main = fromTargetAddress<MainFnPtr>(MainSym.getAddress());
return Main(ArgC, ArgV);
return Main(ArgV.size(), (char**)ArgV.data());
}

4 changes: 2 additions & 2 deletions tools/lli/OrcLazyJIT.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ class OrcLazyJIT {
std::vector<orc::CtorDtorRunner<CODLayerT>> IRStaticDestructorRunners;
};

int runOrcLazyJIT(std::vector<std::unique_ptr<Module>> Ms, int ArgC,
char* ArgV[]);
int runOrcLazyJIT(std::vector<std::unique_ptr<Module>> Ms,
const std::vector<std::string> &Args);

} // end namespace llvm

Expand Down
6 changes: 5 additions & 1 deletion tools/lli/lli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,11 @@ int main(int argc, char **argv, char * const *envp) {
return 1;
}
}
return runOrcLazyJIT(std::move(Ms), argc, argv);
std::vector<std::string> Args;
Args.push_back(InputFile);
for (auto &Arg : InputArgv)
Args.push_back(Arg);
return runOrcLazyJIT(std::move(Ms), Args);
}

if (EnableCacheManager) {
Expand Down

0 comments on commit 95d4f2c

Please sign in to comment.