for my application (uses Builder and MCJIT) I am making the transition LLVM 6.0 -> 8.0.
It runs fine for self-contained functions, but whenever a jit-ed function contains calls to the math library (e.g. @cosf) it seems to have problems getting the address after successfully finding the symbol:
Failure value returned from cantFail wrapped call
UNREACHABLE executed at ~/toolchain/install/llvm-8.0-x86-debug/include/llvm/Support/Error.h:732!
That error message/location indicates that the JIT was able to “find” the ‘cosf’ symbol, but not able to get an address for it. That kind of result is usually restricted to JIT’d code: when the JIT find’s a not-yet-compiled definition, tries to compile it to get a final address, and fails. It sounds like you are using a libm function though, and I would expect that to either not be found at all, or to be found and trivially have an address.
Are you able to provide some more context? Is the code line you shared from LLVM, or your own ORC-based JIT? Do you have a test case that you can share?
Yes, I was able to boil it down to a minimal test case.
The test case uses the KaleidoscopeJIT.h that ships with LLVM 8 (except
that I had to expose the Datalayout). It reads from the filesystem an IR
file (filename “func_works.ll” or "func_cos_fails.ll) and asks the ORC
JIT first for the symbol “func_ir” and then for the address.
In case the file “func_works.ll” was read the program succeeds with:
symbol found!
address found!
In case the file “func_cos_fails.ll” was read the program fails with:
symbol found!
Failure value returned from cantFail wrapped call
UNREACHABLE executed at
install/llvm-8.0-x86-debug/include/llvm/Support/Error.h:732!
Stack dump: