Hi Stephen,<br><br>I confirm your observation. AFAIK the current JIT keeps informations from the module, for example AssertingHandle on Values.<br><br>It's part of my plan to make the MCJIT independent from Module stuff to allow reoptimizations, or to have multiple copies of JITed functions for one function in the module, but there is a long road to go.<br>
<br>Olivier. <br><br><br><div class="gmail_quote">On Tue, Nov 9, 2010 at 6:57 PM, Stephen Kyle <span dir="ltr"><<a href="mailto:stephenckyle@googlemail.com">stephenckyle@googlemail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hi,<br>
<br>
I found the following wiki page in the Unladen Swallow project:<br>
<br>
<a href="http://code.google.com/p/unladen-swallow/wiki/CodeLifecycle" target="_blank">http://code.google.com/p/unladen-swallow/wiki/CodeLifecycle</a><br>
<br>
This would appear to answer my question. Could someone confirm for me<br>
if it's definitely unsafe to attempt to optimise/JIT any Modules while<br>
a different thread is currently executing a JITed function which has<br>
been generated from them? Or am I just missing something here?<br>
<br>
I've tried using llvm::CloneModule() to copy the Module and then work<br>
on that instead to JIT a new function, but it seems that doesn't<br>
always work, or even the cloning process itself causes an assertion to<br>
be raised.<br>
<br>
Thanks in advance for any replies,<br>
<font color="#888888">Stephen<br>
</font><div><div></div><div class="h5"><br>
On 8 November 2010 21:22, Stephen Kyle <<a href="mailto:stephenckyle@googlemail.com">stephenckyle@googlemail.com</a>> wrote:<br>
> Hi,<br>
><br>
> Has anyone had any success with running different PassManagers on<br>
> llvm::Modules they've already JITed and are executing?<br>
><br>
> In detail:<br>
><br>
> 1) getting the IR, in form of an llvm::Module<br>
> 2) calling PassManager->run() on the module<br>
> 3) calling getFunction() and getPointerToFunction() to JIT the module<br>
> 4) executing the JITed code using the function pointer received in step 3<br>
><br>
> and then what I want to do is:<br>
><br>
> 5) using a different PassManager with different (more time-consuming)<br>
> Passes, call run() on the module again<br>
> 6) call getFunction() and getPointerToFunction() again<br>
> 7) use the new function pointer to execute the JITed code instead.<br>
><br>
> As an added complication, different threads may be performing the<br>
> initial compilation or reoptimisation, but before we consider this, is<br>
> there any reason why the above shouldn't work?<br>
><br>
> When I do it, I occasionally get assertion errors such as:<br>
><br>
> <more path...>/RELEASE_28/include/llvm/ADT/APInt.h:819: bool<br>
> llvm::APInt::operator==(const llvm::APInt&) const: Assertion `BitWidth<br>
> == RHS.BitWidth && "Comparison requires equal bit widths"' failed.<br>
> Stack dump:<br>
> 0. Running pass 'Function Pass Manager' on module 'lib0000'.<br>
> 1. Running pass 'Combine redundant instructions' on function '<func name>'<br>
> Aborted<br>
><br>
> or<br>
><br>
> RELEASE_28/lib/VMCore/LeaksContext.h:50: void<br>
> llvm::LeakDetectorImpl<T>::addGarbage(const T*) [with T =<br>
> llvm::Value]: Assertion `Ts.count(o) == 0 && "Object already in set!"'<br>
> failed.<br>
> Stack dump:<br>
> 0. Running pass 'Function Pass Manager' on module 'lib000d'.<br>
> 1. Running pass 'Combine redundant instructions' on function '<func name>'<br>
> Aborted<br>
><br>
> It only happens sometimes, so this would imply some kind of race<br>
> condition between the compliation and reoptimisation threads, but I'm<br>
> definitely not trying to run a PassManager on a module which is<br>
> currently being JITed, so perhaps something about the module is being<br>
> corrupted by the call to the JIT? Hopefully the above assertion checks<br>
> indicate something obvious to someone...?<br>
><br>
> Cheers,<br>
> Stephen<br>
><br>
<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a> <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
</div></div></blockquote></div><br>