diff options
Diffstat (limited to 'llvm/tools/lli')
-rw-r--r-- | llvm/tools/lli/OrcLazyJIT.cpp | 3 | ||||
-rw-r--r-- | llvm/tools/lli/OrcLazyJIT.h | 37 |
2 files changed, 22 insertions, 18 deletions
diff --git a/llvm/tools/lli/OrcLazyJIT.cpp b/llvm/tools/lli/OrcLazyJIT.cpp index d9cec0ce363..a36d5731599 100644 --- a/llvm/tools/lli/OrcLazyJIT.cpp +++ b/llvm/tools/lli/OrcLazyJIT.cpp @@ -144,7 +144,8 @@ int llvm::runOrcLazyJIT(std::vector<std::unique_ptr<Module>> Ms, int ArgC, OrcInlineStubs); // Add the module, look up main and run it. - J.addModuleSet(std::move(Ms)); + for (auto &M : Ms) + J.addModule(std::move(M)); auto MainSym = J.findSymbol("main"); if (!MainSym) { diff --git a/llvm/tools/lli/OrcLazyJIT.h b/llvm/tools/lli/OrcLazyJIT.h index 71e0d839d27..26be63de53e 100644 --- a/llvm/tools/lli/OrcLazyJIT.h +++ b/llvm/tools/lli/OrcLazyJIT.h @@ -38,7 +38,7 @@ public: typedef orc::CompileOnDemandLayer<IRDumpLayerT, CompileCallbackMgr> CODLayerT; typedef CODLayerT::IndirectStubsManagerBuilderT IndirectStubsManagerBuilder; - typedef CODLayerT::ModuleSetHandleT ModuleSetHandleT; + typedef CODLayerT::ModuleSetHandleT ModuleHandleT; OrcLazyJIT(std::unique_ptr<TargetMachine> TM, std::unique_ptr<CompileCallbackMgr> CCMgr, @@ -62,21 +62,18 @@ public: DtorRunner.runViaLayer(CODLayer); } - ModuleSetHandleT addModuleSet(std::vector<std::unique_ptr<Module>> Ms) { - // Attach a data-layouts if they aren't already present. - for (auto &M : Ms) - if (M->getDataLayout().isDefault()) - M->setDataLayout(DL); + ModuleHandleT addModule(std::unique_ptr<Module> M) { + // Attach a data-layout if one isn't already present. + if (M->getDataLayout().isDefault()) + M->setDataLayout(DL); // Record the static constructors and destructors. We have to do this before // we hand over ownership of the module to the JIT. std::vector<std::string> CtorNames, DtorNames; - for (auto &M : Ms) { - for (auto Ctor : orc::getConstructors(*M)) - CtorNames.push_back(mangle(Ctor.Func->getName())); - for (auto Dtor : orc::getDestructors(*M)) - DtorNames.push_back(mangle(Dtor.Func->getName())); - } + for (auto Ctor : orc::getConstructors(*M)) + CtorNames.push_back(mangle(Ctor.Func->getName())); + for (auto Dtor : orc::getDestructors(*M)) + DtorNames.push_back(mangle(Dtor.Func->getName())); // Symbol resolution order: // 1) Search the JIT symbols. @@ -87,18 +84,24 @@ public: [this](const std::string &Name) -> JITSymbol { if (auto Sym = CODLayer.findSymbol(Name, true)) return Sym; - return CXXRuntimeOverrides.searchOverrides(Name); - }, - [](const std::string &Name) { + if (auto Sym = CXXRuntimeOverrides.searchOverrides(Name)) + return Sym; + if (auto Addr = RTDyldMemoryManager::getSymbolAddressInProcess(Name)) return JITSymbol(Addr, JITSymbolFlags::Exported); + + return JITSymbol(nullptr); + }, + [](const std::string &Name) { return JITSymbol(nullptr); } ); // Add the module to the JIT. - auto H = CODLayer.addModuleSet(std::move(Ms), + std::vector<std::unique_ptr<Module>> S; + S.push_back(std::move(M)); + auto H = CODLayer.addModuleSet(std::move(S), llvm::make_unique<SectionMemoryManager>(), std::move(Resolver)); @@ -116,7 +119,7 @@ public: return CODLayer.findSymbol(mangle(Name), true); } - JITSymbol findSymbolIn(ModuleSetHandleT H, const std::string &Name) { + JITSymbol findSymbolIn(ModuleHandleT H, const std::string &Name) { return CODLayer.findSymbolIn(H, mangle(Name), true); } |