[LLVMdev] OCaml bindings to LLVM

Daniel Dunbar daniel at zuster.org
Mon Sep 8 09:23:48 PDT 2008


On Fri, Sep 5, 2008 at 8:26 PM, Jon Harrop
<jonathandeanharrop at googlemail.com> wrote:
> Firstly, I noticed that the execute engine is very slow, taking milliseconds
> to call a JIT compiled function. Is this an inherent overhead or am I calling
> it incorrectly or is this something that can be optimized in the OCaml
> bindings?

What is the signature of the function you are calling?

When calling a generated function via runFunction, the JIT handles some common
signatures but if it doesn't recognize the function signature it falls
back on generating
a stub function on the fly. This generation is fairly expensive and is
probably the overhead
you are seeing. There should be little more inherent overhead than the
cost of a function
call if the stub path isn't being taken.

The simple solution (aside from fixing JIT) is to change your
signature to match one
of the ones the JIT special cases (see JIT::runFunction). A nullary
one with arguments
passed in globals works fine, if thread safety isn't a concern.

 - Daniel



More information about the llvm-dev mailing list