[llvm-dev] lli issue with interpreter - "Unknown constant pointer type!"

Andreas Hug via llvm-dev
Thu, 26 Oct 2017 12:57:16 -0000

Hi all,

I have two problems with the LLVM lli JIT / Interpreter.
First of all I get an error with the following message when the <iostream>
header is included (JIT and Interpreter):
LLVM ERROR: Program used external function '__dso_handle' which could
not be resolved!

This can be resolved by using the -fno-use-cxa-atexit, but is there another way
to avoid this error?

The second issue is that I get the error "Unknown constant pointer
type!" when I try to use lli with -force-interpreter=true.
If I use the JIT, the program works fine.

I produced this error by simply using two classes and two cpp files. If both
classes are defined in the same cpp file, the Interpreter works correctly.

Here are the commands I used:

#Standalone (both classes in one file)

$ clang++ -O3 -std=c++11 -c -emit-llvm ../src/Standalone.cpp -o standalone.bc
$ lli -force-interpreter=false standalone.bc
Result 200

$ lli -force-interpreter=true standalone.bc
Result 200

#Linked Files (classes in separate files)

$ clang++ -O3 -std=c++11 -c -emit-llvm ../src/Calculation.cpp ../src/Main.cpp
$ llvm-link -v Calculation.bc Main.bc -o prog.bc
Loading 'Calculation.bc'
Linking in 'Calculation.bc'
Loading 'Main.bc'
Linking in 'Main.bc'
Writing bitcode...

$ lli -force-interpreter=false prog.bc
Result 200

$ lli -force-interpreter=true prog.bc
Unknown constant pointer type!
UNREACHABLE executed at
/home/ahug/llvm/source/llvm/llvm-5.0.0.src/lib/ExecutionEngine/ExecutionEngine.cpp:914!
#0 0x0000000002dcdf8f (lli+0x2dcdf8f)
#1 0x0000000002dce022 (lli+0x2dce022)
#2 0x0000000002dcc061 (lli+0x2dcc061)
#3 0x0000000002dcd760 (lli+0x2dcd760)
#4 0x00007f28e5512390 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x11390)
#5 0x00007f28e407c428 gsignal
/build/glibc-bfm8X4/glibc-2.23/signal/../sysdeps/unix/sysv/linux/raise.c:54:0
#6 0x00007f28e407e02a abort /build/glibc-bfm8X4/glibc-2.23/stdlib/abort.c:91:0
#7 0x0000000002d31b14 (lli+0x2d31b14)
#8 0x00000000028604ee (lli+0x28604ee)
#9 0x0000000002894e8b (lli+0x2894e8b)
#10 0x000000000288e290 (lli+0x288e290)
#11 0x0000000002895a3d (lli+0x2895a3d)
#12 0x0000000002898c50 (lli+0x2898c50)
#13 0x0000000002897a9b (lli+0x2897a9b)
#14 0x000000000289682f (lli+0x289682f)
#15 0x00000000028953c8 (lli+0x28953c8)
#16 0x000000000287518c (lli+0x287518c)
#17 0x000000000285d696 (lli+0x285d696)
#18 0x00000000020d8532 (lli+0x20d8532)
#19 0x00007f28e4067830 __libc_start_main
/build/glibc-bfm8X4/glibc-2.23/csu/../csu/libc-start.c:325:0
#20 0x00000000020d6029 (lli+0x20d6029)
Stack dump:
0.    Program arguments: lli -force-interpreter=true prog.bc
Aborted (core dumped)

For the background:
I use Ubuntu 16.04.3 LTS x86_64 and LLVM 5.0.0 build from source with libffi
support

Can you say what I am doing wrong here?

The complete code is attached.

Thanks in advance

Sincerely,
Andreas Hug
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20171026/9d909e2a/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: LLVM_Interpreter_Issue.tar.gz
Type: application/octet-stream
Size: 12000 bytes
Desc: not available
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20171026/9d909e2a/attachment-0001.obj>