[llvm-dev] Dynamic recompilation with ORC JIT API

Raoul Gough via llvm-dev llvm-dev at lists.llvm.org
Wed Dec 9 06:40:52 PST 2020


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