summaryrefslogtreecommitdiff
path: root/tools/lli
diff options
context:
space:
mode:
authorLang Hames <lhames@gmail.com>2016-08-02 21:00:40 +0000
committerLang Hames <lhames@gmail.com>2016-08-02 21:00:40 +0000
commitf8cfb2fa655e998d1213f10ca226d2c9ff40bc51 (patch)
treed0a91939f76109ce63528cc4f9810c39431ae7a3 /tools/lli
parent23d7717d3d422a6bb243f6b192560c6e4a53feef (diff)
[lli] Add the ability for OrcLazyJIT to accept multiple input modules.
LLI already supported passing multiple input modules to MCJIT via the -extra-module option. This patch adds the plumbing to pass these modules to the OrcLazy JIT too. This functionality will be used in an upcoming test case for weak symbol handling. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277521 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/lli')
-rw-r--r--tools/lli/OrcLazyJIT.cpp8
-rw-r--r--tools/lli/OrcLazyJIT.h3
-rw-r--r--tools/lli/lli.cpp14
3 files changed, 19 insertions, 6 deletions
diff --git a/tools/lli/OrcLazyJIT.cpp b/tools/lli/OrcLazyJIT.cpp
index 552f5791a10..a36d5731599 100644
--- a/tools/lli/OrcLazyJIT.cpp
+++ b/tools/lli/OrcLazyJIT.cpp
@@ -105,7 +105,8 @@ static PtrTy fromTargetAddress(JITTargetAddress Addr) {
return reinterpret_cast<PtrTy>(static_cast<uintptr_t>(Addr));
}
-int llvm::runOrcLazyJIT(std::unique_ptr<Module> M, int ArgC, char* ArgV[]) {
+int llvm::runOrcLazyJIT(std::vector<std::unique_ptr<Module>> Ms, int ArgC,
+ char* ArgV[]) {
// Add the program's symbols into the JIT's search space.
if (sys::DynamicLibrary::LoadLibraryPermanently(nullptr)) {
errs() << "Error loading program symbols.\n";
@@ -143,8 +144,9 @@ int llvm::runOrcLazyJIT(std::unique_ptr<Module> M, int ArgC, char* ArgV[]) {
OrcInlineStubs);
// Add the module, look up main and run it.
- auto MainHandle = J.addModule(std::move(M));
- auto MainSym = J.findSymbolIn(MainHandle, "main");
+ for (auto &M : Ms)
+ J.addModule(std::move(M));
+ auto MainSym = J.findSymbol("main");
if (!MainSym) {
errs() << "Could not find main function.\n";
diff --git a/tools/lli/OrcLazyJIT.h b/tools/lli/OrcLazyJIT.h
index 72f35ad6ab6..26be63de53e 100644
--- a/tools/lli/OrcLazyJIT.h
+++ b/tools/lli/OrcLazyJIT.h
@@ -156,7 +156,8 @@ private:
std::vector<orc::CtorDtorRunner<CODLayerT>> IRStaticDestructorRunners;
};
-int runOrcLazyJIT(std::unique_ptr<Module> M, int ArgC, char* ArgV[]);
+int runOrcLazyJIT(std::vector<std::unique_ptr<Module>> Ms, int ArgC,
+ char* ArgV[]);
} // end namespace llvm
diff --git a/tools/lli/lli.cpp b/tools/lli/lli.cpp
index be22cc927c2..31979097b93 100644
--- a/tools/lli/lli.cpp
+++ b/tools/lli/lli.cpp
@@ -397,8 +397,18 @@ int main(int argc, char **argv, char * const *envp) {
return 1;
}
- if (UseJITKind == JITKind::OrcLazy)
- return runOrcLazyJIT(std::move(Owner), argc, argv);
+ if (UseJITKind == JITKind::OrcLazy) {
+ std::vector<std::unique_ptr<Module>> Ms;
+ Ms.push_back(std::move(Owner));
+ for (auto &ExtraMod : ExtraModules) {
+ Ms.push_back(parseIRFile(ExtraMod, Err, Context));
+ if (!Ms.back()) {
+ Err.print(argv[0], errs());
+ return 1;
+ }
+ }
+ return runOrcLazyJIT(std::move(Ms), argc, argv);
+ }
if (EnableCacheManager) {
std::string CacheName("file:");