[LLVMdev] Query on llvm-gcc v/s llc/as

Jim Grosbach grosbach at apple.com
Fri Sep 17 11:52:38 PDT 2010


On Sep 17, 2010, at 11:10 AM, Raghu Prabhakar wrote:

> Hi all,
> 
> I have started using LLVM recently, and I have a basic question. There are two different ways in which an executable can be generated from a .c file - by just using llvm-gcc, and using a combination of llvm-gcc (to emit bitcode .bc), llc (to emit assembly code), as (to assemble the code) and collect2 (linker). For example, consider compiling test.c :
> 
> 1) llvm-gcc -O3 test.c -o testExecutable
> 
> 2) llvm-gcc -O3 -emit-llvm -c test.c -o test.bc
>   llc -O3 test.bc -o test.s
>   as test.s -o test.o
>   gcc test.o -o testExecutable2
> 
> My question is, are the two executables (testExecutable and testExecutable2) basically the same ? Is there any huge difference between the two processes which will impact the executable's running time ? I am asking this because I compared the executables by their wordcounts (wc -c), and there was a slight difference. However, when I timed the test runs, both performances were identical.

The two control flows should be basically identical. In practice there may be a few differences due to differing defaults for things like relocation model, processor tuning, etc, between llc and llvm-gcc.  When generating code directly, llvm-gcc uses the same back-end code generator that llc encapsulates, and then calls as and ld to assemble and link the code (pass "-v" to llvm-gcc to see the command lines it's using to do so).

-Jim



More information about the llvm-dev mailing list