Hi Manoel,
CC'ing the dev list, since the answer may be relevant to others...
> Do you have news about Modify a module at runtime in MCJIT?
> We need this feature. Who develops dynamic language like lua, javascript
has the same problem.
MCJIT does not support modification of modules that have already been added
to the JIT. There is nothing preventing you from modifying the IR, but if
the module has already been compiled then your modifications will have no
effect.
To modify code in MCJIT you would usually delete the JIT state containing
the module (often this just means deleting the whole MCJIT instance), then
adding the new version of the Module to the JIT (or building a new MCJIT
instance), then update any callers. How this is done is left up to the
client - MCJIT provides no built-in support.
You can build on MCJIT to do this, and several clients have, but you won't
get much help from the infrastructure. I would suggest the new Orc JIT APIs
instead, as they offer two advantages over MCJIT:
(1) The Orc layers don't take ownership of the IR by default. This means
you can retain ownership of the Module and modify it place.
(2) The Orc layers provide a "removeModuleSet" method that enables you
to
delete the JIT state associated with a particular module (or set of
modules) that you have added. This saves you from manually managing
multiple MCJIT interfaces.
Some of the functions in
"include/llvm/ExecutionEngine/Orc/IndirectionUtils.h" may also be of
use to
you if you want to partition multi-function modules or use stubs to handle
redirecting function calls.
The basic Orc-JIT setup shown in examples/Kaleidoscope/Orc/initial/toy.cpp
may help you get up and running with the new APIs if you would like to try
them.
I hope this helps!
Cheers,
Lang.
On Thu, Mar 26, 2015 at 10:58 PM, Manoel Teixeira <mbsteixeira at
gmail.com>
wrote:
>
> Hello, Lang.
>
> Do you have news about Modify a module at runtime in MCJIT?
> We need this feature. Who develops dynamic language like lua, javascript
> has the same problem.
>
> Cheers,
> Manoel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20150327/d5c593be/attachment.html>