<div dir="ltr">There are no in-tree JITs that use lazy bitcode parsing, so writing a regression test was not possible at the time. I might add lazy bitcode parsing to LLJIT. Then we would be trivially testing this everywhere.<div><br></div><div>-- Lang.</div></div><br><div class="gmail_quote"><div dir="ltr">On Mon, Jun 18, 2018 at 11:46 AM David Blaikie <<a href="mailto:dblaikie@gmail.com">dblaikie@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">Test case? (commit message mentions this avoids a crash - so I'd imagine a test case can be constructed - or was the crash showing up on existing tests (or would show up in existing tests once the additional assertion was included?)?)</div><br><div class="gmail_quote"><div dir="ltr">On Tue, Jun 12, 2018 at 1:47 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 Jun 12 13:43:15 2018<br>
New Revision: 334535<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=334535&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=334535&view=rev</a><br>
Log:<br>
[MCJIT] Call materializeAll on modules before compiling them in MCJIT.<br>
<br>
This only affects modules with lazy GVMaterializers attached (usually modules<br>
read off disk using the lazy bitcode reader). For such modules, materializing<br>
before compiling prevents crashes due to missing function bodies /<br>
initializers.<br>
<br>
Modified:<br>
    llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp<br>
<br>
Modified: llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp?rev=334535&r1=334534&r2=334535&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp?rev=334535&r1=334534&r2=334535&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp (original)<br>
+++ llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp Tue Jun 12 13:43:15 2018<br>
@@ -142,8 +142,14 @@ void MCJIT::setObjectCache(ObjectCache*<br>
 }<br>
<br>
 std::unique_ptr<MemoryBuffer> MCJIT::emitObject(Module *M) {<br>
+  assert(M && "Can not emit a null module");<br>
+<br>
   MutexGuard locked(lock);<br>
<br>
+  // Materialize all globals in the module if they have not been<br>
+  // materialized already.<br>
+  cantFail(M->materializeAll());<br>
+<br>
   // This must be a module which has already been added but not loaded to this<br>
   // MCJIT instance, since these conditions are tested by our caller,<br>
   // generateCodeForModule.<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>
</blockquote></div>