[llvm-dev] Dynamic recompilation with ORC JIT API

Sebastiano Miano via llvm-dev llvm-dev at lists.llvm.org
Wed Dec 9 09:26:02 PST 2020


Hi all,
thanks a lot for your answers and your help.

@Lang it is definitely more clear now! I guess this approach is also
very similar to the one applied to the SpeculativeJIT under the
example folder. Am I right?
The main difference in my use case is that I want to trigger the
recompilation outside of the running function (e.g., because other
external events happened that may impact on the function under
consideration).
I will do some tests in the next few weeks and I will definitely come
back in this thread with other questions.
Then, I will be happy to discuss with you and add some off-the-shelf
support in ORC for this.

@Raoul
This shouldn't happen in my case, but it is a great suggestion and
definitely would have caused me a lot of headaches if I did not know
beforehand.

Thanks again,
Sebastiano

On Wed, 9 Dec 2020 at 15:40, Raoul Gough <github.drti at gmail.com> wrote:
>
> On 07/12/2020 21:08, Lang Hames via llvm-dev wrote:
>
> [snip]
> > In optimize_function you should look up the address of foo_optimized,
> > then use the IndirectStubManager to update the stub with:
> > ISM.updatePointer("foo", foo_optimized_address);
> >
> > There are a couple of gotchas here:
>
> [snip]
>
> You might also have to watch out for the symbols created and used for
> static initialisation and make sure they refer to the existing globals.
> For example if the code you're compiling has something like:
>
> void my_function()
> {
>      static some_type something = something_only_once();
> }
>
> When you recompile my_function you don't want a new copy of something
> with its own initialization guard variables, you'll want to re-use the
> something created the first time my_function ran. In fact if the system
> were really clever the optimised version of my_function wouldn't need
> any of the static initialization checking logic, at least not in this
> simple case. However the main thing is that something_only_once might
> have side-effects which you don't want happening twice because
> my_function got recompiled.
>
> Regards,
> Raoul.
>


More information about the llvm-dev mailing list