<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Tue, Aug 2, 2016 at 2:08 PM Lang Hames via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: lhames<br>
Date: Tue Aug  2 16:00:40 2016<br>
New Revision: 277521<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=277521&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=277521&view=rev</a><br>
Log:<br>
[lli] Add the ability for OrcLazyJIT to accept multiple input modules.<br>
<br>
LLI already supported passing multiple input modules to MCJIT via the<br>
-extra-module option. This patch adds the plumbing to pass these modules to<br>
the OrcLazy JIT too.<br>
<br>
This functionality will be used in an upcoming test case for weak symbol<br>
handling.<br></blockquote><div><br></div><div>Does this only enable functionality for weak symbol handling?<br><br>(or does it, say, make it possible to have a simple two module unlinked situation (one module declares and calls a function, the other module defines that function)? That could be tested without the weak symbol handling)</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
<br>
Modified:<br>
    llvm/trunk/tools/lli/OrcLazyJIT.cpp<br>
    llvm/trunk/tools/lli/OrcLazyJIT.h<br>
    llvm/trunk/tools/lli/lli.cpp<br>
<br>
Modified: llvm/trunk/tools/lli/OrcLazyJIT.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lli/OrcLazyJIT.cpp?rev=277521&r1=277520&r2=277521&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lli/OrcLazyJIT.cpp?rev=277521&r1=277520&r2=277521&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/tools/lli/OrcLazyJIT.cpp (original)<br>
+++ llvm/trunk/tools/lli/OrcLazyJIT.cpp Tue Aug  2 16:00:40 2016<br>
@@ -105,7 +105,8 @@ static PtrTy fromTargetAddress(JITTarget<br>
   return reinterpret_cast<PtrTy>(static_cast<uintptr_t>(Addr));<br>
 }<br>
<br>
-int llvm::runOrcLazyJIT(std::unique_ptr<Module> M, int ArgC, char* ArgV[]) {<br>
+int llvm::runOrcLazyJIT(std::vector<std::unique_ptr<Module>> Ms, int ArgC,<br>
+                        char* ArgV[]) {<br>
   // Add the program's symbols into the JIT's search space.<br>
   if (sys::DynamicLibrary::LoadLibraryPermanently(nullptr)) {<br>
     errs() << "Error loading program symbols.\n";<br>
@@ -143,8 +144,9 @@ int llvm::runOrcLazyJIT(std::unique_ptr<<br>
                OrcInlineStubs);<br>
<br>
   // Add the module, look up main and run it.<br>
-  auto MainHandle = J.addModule(std::move(M));<br>
-  auto MainSym = J.findSymbolIn(MainHandle, "main");<br>
+  for (auto &M : Ms)<br>
+    J.addModule(std::move(M));<br>
+  auto MainSym = J.findSymbol("main");<br>
<br>
   if (!MainSym) {<br>
     errs() << "Could not find main function.\n";<br>
<br>
Modified: llvm/trunk/tools/lli/OrcLazyJIT.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lli/OrcLazyJIT.h?rev=277521&r1=277520&r2=277521&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lli/OrcLazyJIT.h?rev=277521&r1=277520&r2=277521&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/tools/lli/OrcLazyJIT.h (original)<br>
+++ llvm/trunk/tools/lli/OrcLazyJIT.h Tue Aug  2 16:00:40 2016<br>
@@ -156,7 +156,8 @@ private:<br>
   std::vector<orc::CtorDtorRunner<CODLayerT>> IRStaticDestructorRunners;<br>
 };<br>
<br>
-int runOrcLazyJIT(std::unique_ptr<Module> M, int ArgC, char* ArgV[]);<br>
+int runOrcLazyJIT(std::vector<std::unique_ptr<Module>> Ms, int ArgC,<br>
+                  char* ArgV[]);<br>
<br>
 } // end namespace llvm<br>
<br>
<br>
Modified: llvm/trunk/tools/lli/lli.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lli/lli.cpp?rev=277521&r1=277520&r2=277521&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lli/lli.cpp?rev=277521&r1=277520&r2=277521&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/tools/lli/lli.cpp (original)<br>
+++ llvm/trunk/tools/lli/lli.cpp Tue Aug  2 16:00:40 2016<br>
@@ -397,8 +397,18 @@ int main(int argc, char **argv, char * c<br>
     return 1;<br>
   }<br>
<br>
-  if (UseJITKind == JITKind::OrcLazy)<br>
-    return runOrcLazyJIT(std::move(Owner), argc, argv);<br>
+  if (UseJITKind == JITKind::OrcLazy) {<br>
+    std::vector<std::unique_ptr<Module>> Ms;<br>
+    Ms.push_back(std::move(Owner));<br>
+    for (auto &ExtraMod : ExtraModules) {<br>
+      Ms.push_back(parseIRFile(ExtraMod, Err, Context));<br>
+      if (!Ms.back()) {<br>
+        Err.print(argv[0], errs());<br>
+        return 1;<br>
+      }<br>
+    }<br>
+    return runOrcLazyJIT(std::move(Ms), argc, argv);<br>
+  }<br>
<br>
   if (EnableCacheManager) {<br>
     std::string CacheName("file:");<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div></div>