[llvm-dev] How to recompile functions with ORC JIT?

Lang Hames via llvm-dev llvm-dev at lists.llvm.org
Fri May 27 15:15:09 PDT 2016

H Theodoros, David,

What I am trying to figure out is how the function pointer can be updated
> to point to the newly compiled version.

As Dave implied, it depends on how you've set up your ORC stack. These
days, the API directly responsible for this is the IndirectStubsManager
(see llvm/include/llvm/ExecutionEngine/Orc/IndirectionUtils.h). If you have
access to the appropriate IndirectStubsManager you just need to call the
updatePointer method with the name of the function you want to update and
the new address.

If you're using the CompileOnDemand layer to compile lazily from IR, the
problem is that that layer doesn't (currently) expose the
IndirectStubManager for each module. I think it would be reasonable to add
support for that if you need it though.

So - what is your current setup?

You may also be interested in the latest chapter of the Building A JIT
tutorial series that I'm working on. There's no chapter text yet, but the
code was just committed as r271054 and is (hopefully) fairly readable if
you're already familiar with Orc.


On Fri, May 27, 2016 at 10:38 AM, David Blaikie <dblaikie at gmail.com> wrote:

> +Lang
> Ultravague answer: There are a few different Orc layers for different
> levels of indirection needed for different levels of substitutability. One
> way is to indirect every call through global function pointers - so when
> you want to replace the function you write the new function pointer to the
> global variable. I forget which layers do which kinds of indirection.
> - Dave
> On Thu, May 26, 2016 at 11:49 PM, Theodoros Theododiris via llvm-dev <
> llvm-dev at lists.llvm.org> wrote:
>> Hello,
>> I am trying to figure out how to recompile functions multiple times
>> during run-time with ORC JIT
>> and I'd appreciate any help/advice.
>> My use case is t he following: every time a function of interest
>> (annotated) is called, profiling data
>> are gathered. Given enough data the function is recompiled using
>> different optimizations. This happens
>> repeatedly until the "best" optimization parameters are found.
>> A similar question was asked before and a solution was suggested:
>> http://lists.llvm.org/pipermail/llvm-dev/2015-July/088665.html
>> What I am trying to figure out is how the function pointer can be updated
>> to point to the newly
>> compiled version.
>> Thanks,
>> Theodor
>> _______________________________________________
>> LLVM Developers mailing list
>> llvm-dev at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160527/3027be7f/attachment.html>

More information about the llvm-dev mailing list