[LLVMdev] What llvm tool will llvm-gcc call in each phase?
Devang Patel
dpatel at apple.com
Wed Feb 27 10:34:08 PST 2008
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
More information about the llvm-dev
mailing list