[LLVMdev] linking individual functions in execution module

charles quarra charllsnotieneningunputocorreo at gmail.com
Wed Nov 21 12:42:55 PST 2012


Hi,


JIT does not allow functions to call others in different modules, so
all modules need to be statically linked in a big fat module. If a
module needs to be recompiled, all the others need to as well as
relinked.

there are two ways i intend to approach this problem:

1) forget about JITing, build each module into a .bc, call gcc to
generate .soname libraries, dynamically load with dlopen() those
libraries

2) keep the modules unlinked, and when execution is required, link the
required dependencies into an execution module. When one of the
dependencies is changed, most of the modules do not need to be rebuilt
(althought i probably will need to clone the module, since the Linker
seems to be destructive of the source), they just need to be relinked
in the execution module


first approach is my fallback approach, it is obviously rock-solid,
but i don't know how much overhead this actually represents, specially
if an alternative exists

i have questions regarding 2nd approach. each of the modules will have
the functions with generated IR, and among those generated IR will be
generated CallInst and InvokeInst to functions in the other modules.
The questions would be:

A) if i use the Linker class to link two or more modules, do i need to
update the CallInst/InvokeInst or it is part of its job to take care
of those?

B) Can i safely clone the modules before linking them into the
execution module? it seems the Linker is destructive on its sources,
but i don't know how much cycles would cloning the module save, as i'm
not clear if the module generation is more expensive than the linkage
itself


any high-level recommendations and suggestions are welcome



More information about the llvm-dev mailing list