<font face="arial,helvetica,sans-serif"><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; "><font face="arial,helvetica,sans-serif">In my case, I am working on a posix regular expression library that uses LLVM to execute a regular expression.</font><div>

<font face="arial,helvetica,sans-serif">Each regular expression is a very small sets of code and is faster to interpret than to JIT then execute.</font><div><font face="arial,helvetica,sans-serif">I wanted to JIT only when the regular expression is executed more than 20 times.</font></div>

<div><font face="arial,helvetica,sans-serif">The benchmarks I have run show that my library is amzingly fast to execute a regular expression (thanks to LLVM) but amzingly slow to compile in JIT.</font></div><div><font face="arial,helvetica,sans-serif">I need the interpreter to provide a way to execute a regular expression without JITing it, which would be much slower BUT will result in a faster execution IF the regular expression is used only two or three times.</font></div>

<div><font face="arial,helvetica,sans-serif"><br></font></div><div><font face="arial,helvetica,sans-serif">So, is there no way now to execute a LLVM bitcode *without* JITing ?</font></div></div></span></font><br><div class="gmail_quote">

On Tue, Nov 2, 2010 at 19:00, OvermindDL1 <span dir="ltr"><<a href="mailto:overminddl1@gmail.com">overminddl1@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

Helps to send to list:<br>
<div><div></div><div class="h5"><br>
On Tue, Nov 2, 2010 at 1:00 PM, OvermindDL1 <<a href="mailto:overminddl1@gmail.com">overminddl1@gmail.com</a>> wrote:<br>
> On Tue, Nov 2, 2010 at 12:51 PM, Salomon Brys <<a href="mailto:salomon.brys@gmail.com">salomon.brys@gmail.com</a>> wrote:<br>
>> Hi everyone !<br>
>> I am very new to LLVM and intent to use it in a research project.<br>
>> I have a problem with the interpreter: I have a simple compiler that<br>
>> generates LLVM bitcode, JIT it and execute it, and it works very well.<br>
>> Now I would like to execute it using the interpreter. And I get a segfault.<br>
>> Here is the code :<br>
>> // This code JIT the function and executes it<br>
>> llvm::InitializeNativeTarget();<br>
>> llvm::ExecutionEngine * EJ  = llvm::ExecutionEngine::create(&nM);<br>
>> typedef int (*REFunc)(const char *);<br>
>> union { void * obj; REFunc func; } u;<br>
>> u.obj = EJ->getPointerToFunction(func);<br>
>> REFunc jit = u.func;<br>
>> int ret = jit("aaa");<br>
>> std::cout << std::endl << ret << std::endl;<br>
>> // This code interprets the function<br>
>> llvm::initializeCore();<br>
>> llvm::ExecutionEngine * EI  =<br>
>> llvm::EngineBuilder(&M).setEngineKind(llvm::EngineKind::Interpreter).create();<br>
>> EI->runStaticConstructorsDestructors(false);<br>
>> std::vector<llvm::GenericValue> args;<br>
>> llvm::GenericValue arg1((void*)"aaabc");<br>
>> args.push_back(arg1);<br>
>> llvm::APInt res = EI->runFunction(func, args).IntVal;<br>
>> llvm::outs() << res << "\n";<br>
>> The first block of code works very well and write the expected result.<br>
>> The second block segfaults on the EI->runFunction(func, args) call.<br>
>> I can't find my mistake. Would somebody help me on this ???<br>
>> Thank you very much !<br>
><br>
> The interpreter is probably broken.  Since the JIT became stable the<br>
> interpreter is falling to bitrot, so it is better not to use it, just<br>
> use the JIT.  Why do you need the interpreter anyway if the JIT is<br>
> working for you?<br>
><br>
<br>
</div></div>_______________________________________________<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>
</blockquote></div><br><br clear="all"><br>-- <br>###########################################<br># Salomon BRYS<br># +33 (0) 6 83 54 55 96<br>#------------------------------------------<br># > EPITECH "Koala" : C++ assistant : Sbire du C++<br>

# > Zend Certified Engineer for PHP5<br>#------------------------------------------<br># All data in this e-mail is confidential.<br># If you are not, or if you don't believe you are, the recipient of this e-mail, please delete it.<br>

#------------------------------------------<br># GPG : <a href="http://gpgkey-salomon.antesocial.fr/">http://gpgkey-salomon.antesocial.fr/</a><br>###########################################<br>