Hi Jeffrey,<br><br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><br>
==============================================================================<br>
--- llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp (original)<br>
+++ llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp Thu Dec 17 15:35:29 2009<br>
@@ -517,9 +517,15 @@<br>
   void *Actual = TheJIT->isCompilingLazily()<br>
     ? (void *)(intptr_t)LazyResolverFn : (void *)0;<br>
<br>
+  // TODO: Delete this when PR5737 is fixed.<br>
+  std::string ErrorMsg;<br>
+  if (TheJIT->materializeFunction(F, &ErrorMsg)) {<br>
+    llvm_report_error("Error reading function '" + F->getName()+<br>
+                      "' from bitcode file: " + ErrorMsg);<br>
+  }<br></blockquote><div><br></div><div>This should be guarded by a lazy compilation enabled check.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

   // If this is an external declaration, attempt to resolve the address now<br>
   // to place in the stub.<br>
-  if (F->isDeclaration() && !F->hasNotBeenReadFromBitcode()) {<br>
+  if (F->isDeclaration() || F->hasAvailableExternallyLinkage()) {<br></blockquote><div><br></div><div>Why remove the hasNotBeenReadFromBitcode? The hasNotBeenReadFromBitcode function verifies that the linkage of the function is GhostLinkage, which is used by lazy compilation. So users that use lazy compilation require the call to hasNotBeenReadFromBitcode.</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
     Actual = TheJIT->getPointerToFunction(F);<br>
<br>
     // If we resolved the symbol to a null address (eg. a weak external)<br>
@@ -552,7 +558,7 @@<br>
   // exist yet, add it to the JIT's work list so that we can fill in the stub<br>
   // address later.<br>
   if (!Actual && !TheJIT->isCompilingLazily())<br>
-    if (!F->isDeclaration() || F->hasNotBeenReadFromBitcode())<br>
+    if (!F->isDeclaration() && !F->hasAvailableExternallyLinkage())<br>
       TheJIT->addPendingFunction(F);<br></blockquote><div><br></div><div>Likewise.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
   return Stub;<br>
@@ -755,9 +761,16 @@<br>
     void *ResultPtr = TheJIT->getPointerToGlobalIfAvailable(F);<br>
     if (ResultPtr) return ResultPtr;<br>
<br>
+    // TODO: Delete this when PR5737 is fixed.<br>
+    std::string ErrorMsg;<br>
+    if (TheJIT->materializeFunction(F, &ErrorMsg)) {<br>
+      llvm_report_error("Error reading function '" + F->getName()+<br>
+                        "' from bitcode file: " + ErrorMsg);<br>
+    }<br>
+<br></blockquote><div><br></div><div>Add the guard for enabled lazy compilation.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
     // If this is an external function pointer, we can force the JIT to<br>
     // 'compile' it, which really just adds it to the map.<br>
-    if (F->isDeclaration() && !F->hasNotBeenReadFromBitcode())<br>
+    if (F->isDeclaration() || F->hasAvailableExternallyLinkage())<br>
       return TheJIT->getPointerToFunction(F);<br>
   }<br></blockquote><div><br></div><div>Don't remove the hasNotBeenReadFromBitcode.</div><div> </div><div><br></div><div>Hope that still fixes the PR!</div><div><br></div><div>Cheers,</div><div>Nicolas</div></div>