[LLVMdev] Using llvm-gcc with a simple program and the '-c' option

Wink Saville wink at saville.com
Sun Feb 26 22:00:18 PST 2006


Robert,

Thanks for the info, you've confirmed what I was trying to do, but when 
I compile:

-----------------------
#include <stdio.h>

int main(int argc, char *argv[])
{
    printf("yo\n");
    return 0;
}
-----------------------

without "-c" (llvm-gcc t1.c -o t1) the dissassembled bytecode does not 
call __main:

-----------------------
; ModuleID = '<stdin>'
target endian = little
target pointersize = 32
target triple = "i686-pc-linux-gnu"
deplibs = [ "c", "crtend" ]
    %struct..TorRec = type { int, void ()* }
    %struct.TorRec = type { int, void ()* }
%.str_1 = internal constant [4 x sbyte] c"yo\0A\00"        ; <[4 x 
sbyte]*> [#uses=1]

implementation   ; Functions:

declare int %printf(sbyte*, ...)

int %main(int %argc, sbyte** %argv) {
entry:
    %tmp.0 = tail call int (sbyte*, ...)* %printf( sbyte* getelementptr 
([4 x sbyte]* %.str_1, int 0, int 0) )        ; <int> [#uses=0]
    ret int 0
}
-----------------------

But if I use the "-c" option (llvm-gcc -c t1.c -o t1.bc) the bytecode is:

-----------------------
; ModuleID = '<stdin>'
target endian = little
target pointersize = 32
target triple = "i686-pc-linux-gnu"
deplibs = [ "c", "crtend" ]
%.str_1 = internal constant [4 x sbyte] c"yo\0A\00"        ; <[4 x 
sbyte]*> [#uses=1]

implementation   ; Functions:

declare int %printf(sbyte*, ...)

int %main(int %argc, sbyte** %argv) {
entry:
    tail call void %__main( )
    %tmp.0 = tail call int (sbyte*, ...)* %printf( sbyte* getelementptr 
([4 x sbyte]* %.str_1, int 0, int 0) )        ; <int> [#uses=0]
    ret int 0
}

declare void %__main()
--------------------------

Note the call to %__main.

Wink






More information about the llvm-dev mailing list