[LLVMdev] JIT : Does it cache the compiled code of executed functions upon runFunction(..)?
Reid Kleckner
rnk at mit.edu
Thu Mar 18 07:48:08 PDT 2010
Sure, it caches the code for the function you're calling, but because
the JIT doesn't want to get involved in target specific calling
conventions, it codegens a little entry point if your function
prototype is unfamiliar. I think this is NOT cached, which is why you
have slow code. If you statically know your function prototype, I
recommend calling getPointerToFunction and casting the return function
pointer to the right type and calling it directly from your code.
This forces your (static) compiler to generate the right code for the
calling convention.
Reid
On Thu, Mar 18, 2010 at 10:35 AM, Olivier Meurant
<meurant.olivier at gmail.com> wrote:
> Hi Gabi,
>
> I have no idea why your performances is not as expected with such low level
> of informations.
>
> But, I know that the binary code is cached by the JIT. You can find the code
> in JIT.cpp to convince yourself :
> runFunction -> getPointerToFunction ->getPointerToGlobalIfAvailable which
> returns the native address of the jitted function.
>
> You can even try to measure time needed by each runFunction to run to
> double-convince yourself. :)
>
> Olivier.
>
>
> On Thu, Mar 18, 2010 at 9:21 AM, Gabi <bugspynet at gmail.com> wrote:
>>
>> Hello
>> I have the following scenario, and I am not sure why the performance
>> is so bad (take 30 minutes to complete with very simple generated
>> functions):
>>
>> 1. Create module
>> 2. Do something like EE =
>> EngineBuilder(theModule).setEngineKind(EngineKind::JIT).create();
>> 3. Create a function in the module: theModule->getOrInsertFunction(..)
>> 4. Execute 1000 times the function using EE->runFunction(function,
>> args) with different args in each round.
>>
>> My question - Does section 4 above makes the EE recompile the function
>> 1000 times? If no, why is the performance is so bad? what am I doing
>> wrong ? Maybe I should somehow cache the function's binary code?
>>
>>
>> llvm-version 2.7
>> OS: Linux 2.6.31 64 bits (intel dual core, 4GB memory)
>>
>> --
>> Regards,
>> Gabi
>>
>> http://bugspy.net
>> _______________________________________________
>> LLVM Developers mailing list
>> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
>
More information about the llvm-dev
mailing list