[llvm-dev] Orc JIT vs. implicit template instanciation in LLVM 8

Geoff Levner via llvm-dev llvm-dev at lists.llvm.org
Fri Sep 13 08:03:12 PDT 2019


The short version:

When I port our application from LLVM 7 to 8, some JIT-compiled code
seems to break the implicit instanciation of C++ templates. That is,
when I try to resolve a symbol defined by the code, I get undefined
symbols corresponding to methods that are actually function templates.
If the code adds explicit template instanciations, the problem goes
away.

Does anybody have an intuition as to what might cause this?

Now the longer version:

Specifically, we use the Orc JIT (v1) to compile and execute C++ code
on the fly. To move to LLVM 8, I am using the corresponding "legacy"
classes before attempting the move to Orc v2. But when I do that, some
code which compiles fine with LLVM 7 breaks. I might get an undefined
symbol like the following when I try to resolve a symbol defined by
the code, after running constructors (successfully):

    _ZNSt6vectorIfSaIfEE17_M_default_appendEm

Unmangled, that's:

    std::vector<float, std::allocator<float> >::_M_default_append(unsigned long)

which is a function template defined by the C++ vector header file. If
I add an explicit instanciation like so:

    template class std::vector<float>;

the problem goes away. I have tried to reproduce the problem with the
Clang front end to no avail, so I assume it is specific to symbol
resolution in Orc JIT. Has something changed there between LLVM 7 and
8?

Any help would be much appreciated!

Thanks,
Geoff


More information about the llvm-dev mailing list