Problem running program with LLVM JIT

Hey all,
I compiled the code using both the -c and -S options. I can get the human readable IR but I still cannot run it using lli.

The output of the IR looks like this. Can some of the information tell me about why the program is not running.

; ModuleID = 'Hel.c'
target datalayout = "e-p:32:32"
target endian = little
target pointersize = 32
target triple = "i686-pc-linux-gnu"
%str = internal constant [10 x sbyte] c"Hey there\00" ; <[10 x sbyte]*> [#uses=1]

implementation ; Functions:

int %main() {
entry:
        %retval = alloca int, align 4 ; <int*> [#uses=2]
        %tmp = alloca int, align 4 ; <int*> [#uses=2]

These are the lines of code I guess which will have all the information that is causing the error.

Some enlightenment on this please.

Karhu, Abhinav R wrote:

Hey all,
I compiled the code using both the -c and -S options. I can get the human readable IR but I still cannot run it using lli.
  

You need to assemble the human-readable IR into bitcode before it can be executed with lli. To assemble the bitcode, use the llvm-as tool.

FYI, using the -c option with -emit-llvm option in llvm-gcc/llvm-g++ will automatically generate an LLVM bitcode file instead of an LLVM assembly file. You may find this faster than compiling to LLVM assembly, then assembling with llvm-as, and then running with lli.

The following worked for me on my Linux machine:

llvm-gcc -c -emit-llvm test.c
lli test.o

-- John T.

Karhu, Abhinav R wrote:

The output of the IR looks like this. Can some of the information tell me about why the program is not running.

; ModuleID = 'Hel.c'
target datalayout = "e-p:32:32"
target endian = little
target pointersize = 32
target triple = "i686-pc-linux-gnu"
%str = internal constant [10 x sbyte] c"Hey there\00" ; <[10 x sbyte]*> [#uses=1]

implementation ; Functions:

int %main() {
entry:
        %retval = alloca int, align 4 ; <int*> [#uses=2]
        %tmp = alloca int, align 4 ; <int*> [#uses=2]

These are the lines of code I guess which will have all the information that is causing the error.

Whoa, that syntax is ancient. This is pre-2.0 syntax, at least.

Make sure you don't have mixed versions of LLVM or LLVM-GCC installed.

Nick