<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Mon, Aug 8, 2016 at 11:41 AM Lang Hames <<a href="mailto:lhames@gmail.com">lhames@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Dave,</div><div dir="ltr"><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span style="font-size:12.800000190734863px">Does this only enable functionality for weak symbol handling?</span><br style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">(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)</span></blockquote><div><span style="font-size:12.800000190734863px"><br></span></div></div><div dir="ltr"><div><span style="font-size:12.800000190734863px">Interesting. We have basic multi-module tests for MCJIT and OrcMCJITReplacement, but we don't have one for OrcLazy yet. I didn't think to add one for this patch because multi-module functionality will be implicitly tested by the weak symbol test: To test weak symbols you have two modules M1 and M2 that each contain a definition of a weak symbol A. M1 also contains a main function, and M2 contains a non-weak function 'foo' that returns the address of 'A'. To test weak symbol support you verify that 'main' and 'foo' agree on the address of 'A'. If they agree then everything works. If they disagree then weak symbol support is broken, but multi-module support works. If multi-module support is broken the test will refuse to run at all (returning an "symbol 'foo' not found" error).</span></div></div></blockquote><div><br></div><div>Ah - thanks for the explanation/details!</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><span style="font-size:12.800000190734863px"> Given that the failure mode is clear I'd be inclined to just have the one test case with a comment explaining that. What do you think?</span></div></div></blockquote><div><br></div><div>I'd still be inclined to test this separately (so it's covered if the other patch is reverted for example), personally.<br><br>- Dave</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><span style="font-size:12.800000190734863px"><br></span></div><div><span style="font-size:12.800000190734863px">- Lang.</span></div><div><span style="font-size:12.800000190734863px"><br></span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Aug 8, 2016 at 10:29 AM, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><br><div class="gmail_quote"><span><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" target="_blank">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></span><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 class="m_-595471254730971431h5"><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></div></div>
</blockquote></div><br></div>
</blockquote></div></div>