[llvm-dev] dynamic namespacing of JIT modules?

Alex Denisov via llvm-dev llvm-dev at lists.llvm.org
Wed Sep 12 14:47:28 PDT 2018


Not sure if I’ve got your question right.
Do you want to “redirect” calls from the main module to different functions
from different modules? It would help to understand the problem if you
elaborate a bit.

As of this one:

> 1. Assign each module a unique namespace when its bitcode is loaded:
> go through the IR and add the namespace to the names of the functions
> defined (and called, in the case of internal functions). I don't know
> how to do that. Perhaps somebody else does?

you can simply iterate over all the functions and change their names, e.g.:

   function.setName(“foobar” + function.getName())

> On 12. Sep 2018, at 12:09, Geoff Levner via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> 
> Greetings, LLVM wizards!
> 
> We have an application that uses Clang and Orc JIT to compile and
> execute C++ code on the fly.
> 
> The JIT contains any number of LLVM modules, each of which defines a
> function, plus a "main" module that calls those functions. Several
> functions may have the same signature, so I need to find a way to
> resolve them.
> 
> Originally, I just put each module's code in its own namespace when it
> was compiled. But now we want to be able to compile them separately to
> bitcode files and read them later. So at compilation time there is no
> longer any way to assign a unique namespace to each.
> 
> I have a couple ideas for possible solutions, but I'm hoping some LLVM
> expert out there has a better one...
> 
> 1. Assign each module a unique namespace when its bitcode is loaded:
> go through the IR and add the namespace to the names of the functions
> defined (and called, in the case of internal functions). I don't know
> how to do that. Perhaps somebody else does?
> 
> 2. Assign each module a unique namespace, but don't change the modules
> themselves: just add the namespace when a function is called from the
> main module, and modify the JIT's symbol resolver to strip the
> namespace and look for the function only in the relevant module.
> 
> Help...?
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 529 bytes
Desc: Message signed with OpenPGP
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180912/b3986e04/attachment.sig>


More information about the llvm-dev mailing list