[llvm-dev] dynamic namespacing of JIT modules?

Geoff Levner via llvm-dev llvm-dev at lists.llvm.org
Wed Sep 12 03:09:24 PDT 2018


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...?


More information about the llvm-dev mailing list