clang vs llc

Hi,

I think I understand reasonably well what the following does:

~> clang foo.c -emit-llvm -c -o foo.bc
~> llc foo.bc -O3 -o foo.o

However, I am not quite sure about the straightforward

~> clang foo.c -c -o foo.o

Is the latter doing just the same as the former but all in memory? If not, what are the differences?

Luc Bourhis
Computer Scientist
Chemical Crystallography Laboratory
University of Durham, UK

They're doing essentially the same thing.

-Eli

That was my naive expectation in the first place but then I stumbled upon one of Jeffrey Yasskin's comment in a recent thread:

"The tricky bit for clang seems to be that LLVM is good at propagating constants, but clang isn't, so we may have to generate more IR [...]"

Hence my question.

Luc

The comparison there is between the clang generator for LLVM IR (part
of the clang source) and the LLVM IR optimizers (part of the general
LLVM source). clang has to finish generating IR before we can run the
optimizers.

clang is all linked into one binary, but it still goes through the
same steps as if it generated an IR file, ran opt over it, then ran
llc over the result.

-Eli