[llvm-dev] MCJIT, can't use with math functions

Frank Winter via llvm-dev llvm-dev at lists.llvm.org
Mon Apr 1 07:45:38 PDT 2019

Hi Lang!

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
Stack dump:

This was tested on an x86 Linux Ubuntu system.

LLVM was configured with

cmake -G "Unix Makefiles" \
       -DCMAKE_BUILD_TYPE="Debug" \

I hope that makes it easier to see what's going on.


On 3/29/19 5:37 PM, Lang Hames wrote:
> Hi Frank,
> 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?
> Cheers,
> Lang.
> On Fri, Mar 22, 2019 at 1:43 PM Frank Winter via llvm-dev 
> <llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org>> wrote:
>     Hi,
>     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!
>     if (auto Sym = CompileLayer.findSymbol(MangledNameStream.str(),true))
>          {
>            void* fptr = (void *)cantFail(Sym.getAddress());
>     The last statement fails with the above message.
>     Has anything related to using MCJIT with math library functions
>     changed
>     since LLVM 6.0?
>     Best,
>     Frank
>     _______________________________________________
>     LLVM Developers mailing list
>     llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org>
>     https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>     <https://gcc01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.llvm.org%2Fcgi-bin%2Fmailman%2Flistinfo%2Fllvm-dev&data=02%7C01%7Cfwinter%40jlab.org%7Ca89da3e7b6744855dc1308d6b48eb52f%7Cb4d7ee1f4fb34f0690372b5b522042ab%7C1%7C1%7C636894922351400719&sdata=IX3IZBCWPU0xIN44ODXU9jFonCRTDeRpGARZt0fJVBU%3D&reserved=0>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190401/96ff88a7/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: jit_fails.tgz
Type: application/x-compressed-tar
Size: 3054 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190401/96ff88a7/attachment.bin>

More information about the llvm-dev mailing list