[LLVMdev] problem with lli (llvm 1.3)
Shukang Zhou
zhou at cs.virginia.edu
Thu Oct 7 15:22:34 PDT 2004
Hi,
I am working with llvm 1.3 on a sparcv9 machine. I have successfully built
llvm and llvm-gcc frontend. I can run many tools including llvmgcc,
llvm-dis, and llc. After using /opt/SUNWspro/bin/cc to assemble .s file
into a program binary, I can run the binary correctly as well.
I am interested in the JIT compiler (lli). When I directly run the
LLVM bytecode using interpretation ("lli -force-interpreter=true test.bc),
it works fine. But if I use the JIT compiler ("lli
-force-interpreter=false test.bc"), I got a Segmentation Fault error,
even for a small program like helloworld.
If running with gdb, the error looks like
---------------------
(gdb) r test2.bc
Starting program: /a/athena/uf24/zhou/research/llvm/src/tools/Debug/lli
test2.bc
Program received signal SIGSEGV, Segmentation fault.
0xff18505c in _doprnt () from /usr/lib/libc.so.1
(gdb) bt
#0 0xff18505c in _doprnt () from /usr/lib/libc.so.1
#1 0xff1885fc in printf () from /usr/lib/libc.so.1
#2 0xfe07ffe4 in ?? ()
#3 0xfe07ffe4 in ?? ()
Previous frame identical to this frame (corrupt stack?)
---------------------
I think the error comes because there is a system call (printf) in the
test program. I wrote another small program which explicitly uses
three system calls (fopen, fwrite, and fclose). And I also got a
segmentation fault, as:
----------------------
(gdb) r test3.bc
Starting program: /a/athena/uf24/zhou/research/llvm/src/tools/Debug/lli
test3.bc
Program received signal SIGSEGV, Segmentation fault.
0xff370730 in memcpy () from
/usr/platform/SUNW,Sun-Fire-280R/lib/libc_psr.so.1
(gdb) bt
#0 0xff370730 in memcpy ()
from /usr/platform/SUNW,Sun-Fire-280R/lib/libc_psr.so.1
#1 0xfe07ffe4 in ?? ()
#2 0xfe07ffe4 in ?? ()
Previous frame identical to this frame (corrupt stack?)
----------------------
However, if the program doesn't do anything (i.e., an empty main()
function). The lli won't crash.
I traced lli using gdb, and found that it crashes within
JIT::runFunction(). In particular, the problem is in line 70 of JIT.cpp:
int ExitCode = PF(ArgValues[0].IntVal, (char **) GVTOP (ArgValues[1]),
(const char **) GVTOP (ArgValues[2]));
Is anybody having any idea about this? Thanks a lot.
Shukang Zhou
More information about the llvm-dev
mailing list