Guang-Yuan.Wang
2008-Feb-27 13:57 UTC
[LLVMdev] What llvm tool will llvm-gcc call in each phase?
Dear all, I have installed llvm-gcc and llvm-2.2 successfully, now I have been puzzled. Suppose I have a file test.c, If i use llvm-gcc -o test.out test.c then what llvm tool will llvm-gcc call in each step? if I use llvm-gcc -O2 -o test.out test.c then the argument '-O2' will be pass to opt? that is all the optimization is done by opt or llvm will benefit some optimization from gcc? I have try to grep "llc" etc in llvm-gcc source code but have find nothing. Thanks. -- I am young,so my heart is full of dream
Duncan Sands
2008-Feb-27 15:04 UTC
[LLVMdev] What llvm tool will llvm-gcc call in each phase?
Hi,> Suppose I have a file test.c, If i use > > llvm-gcc -o test.out test.c > > then what llvm tool will llvm-gcc call in each step?none, it is linked directly to the LLVM libraries.> if I use llvm-gcc -O2 -o test.out test.c > > then the argument '-O2' will be pass to opt? that is all the > optimization is done by opt or llvm will benefit some optimization from > gcc?It chooses a set of passes to run based on the -O option.> I have try to grep "llc" etc in llvm-gcc source code but have find > nothing.Look in createOptimizationPasses in llvm-backend.cpp. Ciao, Duncan.
Devang Patel
2008-Feb-27 18:34 UTC
[LLVMdev] What llvm tool will llvm-gcc call in each phase?
On Feb 27, 2008, at 5:57 AM, Guang-Yuan.Wang wrote:> Dear all, > > I have installed llvm-gcc and llvm-2.2 successfully, now I have been > puzzled. > > Suppose I have a file test.c, If i use > > llvm-gcc -o test.out test.c > > then what llvm tool will llvm-gcc call in each step? > > if I use llvm-gcc -O2 -o test.out test.c > > then the argument '-O2' will be pass to opt? that is all the > optimization is done by opt or llvm will benefit some optimization > from > gcc?llvm-gcc is a stand alone compiler like gcc. It accepts all standard gcc command line options and llvm-gcc produces assembly code, object file, executable or preprocessed source file depending upon the command line options. llvm-gcc does not invoke any llvm tool directly. llvm-gcc compiler uses llvm optimizer and code generator instead of gcc optimizer and code generator. These llvm optimizer and code generators are directly linked into llvm-gcc compiler. llvm-backend.cpp is the source file where llvm-gcc selects various optimization passes and code generator features based on command line options. llvm-gcc supports two additional command line options, --emit-llvm and -O4, which are not supported by standard GCC. These options instructs llvm-gcc to emit llvm bitcode instead of target specific assembly file or object file. You can use various llvm tools to operate on llvm bitcode. llvm-gcc is one way to generate llvm bitcode, but it is not necessarily only way to generate llvm bitcode. llvm IR is a well described language. 'opt' is a stand alone tool that optimizes llvm bitcode using specified optimization passes. Use opt --help for more info. 'llc' is a stand alone tool that generates target specific assembly code from llvm bitcode. You can feed 'llc' output to an assembler (e.g. gas) to generate object file for your target. - Devang