Some understanding of LLVM vs gCC vs Intel C++ Compilers

Hi All,

I have spent a better part of my 32 years on this earth writing Solaris software and more recently leaving that and returning back to Mac OS.

I obviously know about GCC and the Intel C++ Compilers.

I am looking to have more freedom and flexibility along with producing better quality software.

How does LLVm fit in?

I know that it is a C/C++ Compiler, but how do I use it? Is it Makefile based?

Does it replace GCC?

Can one build full OS X applications with it? (What I mean is dont need to use XCode or anything if I dont want to)

I would totally appreciate advice!

Thanks,

-Jason

From: Jason Todd Slack-Moehrle <mailinglists@mailnewsrss.com>
To: llvmdev@cs.uiuc.edu
Sent: Sunday, June 14, 2009 8:09:03 PM
Subject: [LLVMdev] Some understanding of LLVM vs gCC vs Intel C++ Compilers

Hi All,

Hello Jason,

I know that it is a C/C++ Compiler, but how do I use it? Is it
Makefile based?

Wrong. LLVM-GCC is a frontend for LLVM that converts C/C++ code into the intermediate representation that is LLVM.

Does it replace GCC?

It uses a special version of GCC currently to generate its bitcode from C/C++. There is a GCC replacement called Clang that is coming up but not mature yet.

LLVM stands for Low-Level Virtual Machine. It is an open-source, cross-architecture compiler infrastructure. It runs on and generates code for MacOSX 10.4+ for both PPC and Intel, Windows XP+, Linux on several processor types, and others in the works.

With some effort, it is possible to write a compiler to generate bitcode that will run on any processor independently of the one it was written on. It does not have a thick abstraction layer like .NET or Java, however. For that extension you'll want to look into VMKit which is another implementation of Java and .NET using LLVM. Anther compiler that is going to use the LLVM architecture is Google's Unladen Swallow project which aims to make the Python programming language execute 5 times faster.

I hope this answers some of you questions,

--Sam

Hi All,

Hi Jason,

Sam's response is right on for general guidance, here is some mac-specific guidance.

I have spent a better part of my 32 years on this earth writing
Solaris software and more recently leaving that and returning back to
Mac OS.

I obviously know about GCC and the Intel C++ Compilers.

I am looking to have more freedom and flexibility along with producing
better quality software.

How does LLVm fit in?

The llvm project provides two open source compilers, llvm-gcc and clang. Clang is considered production quality on the mac for C and ObjC. llvm-gcc on the mac supports c/objc/c++/objc++. Apple productizes these and ships them with the Xcode installation.

I know that it is a C/C++ Compiler, but how do I use it? Is it
Makefile based?

Does it replace GCC?

Both llvm-gcc and clang work as drop in replacements for GCC. They take the same command line options etc, and are both quite usable on the command line.

Can one build full OS X applications with it? (What I mean is dont
need to use XCode or anything if I dont want to)

Yes, absolutely.

-Chris

Hi Chris,

Thanks for the response.

How does LLVm fit in?

The llvm project provides two open source compilers, llvm-gcc and
clang. Clang is considered production quality on the mac for C and
ObjC. llvm-gcc on the mac supports c/objc/c++/objc++. Apple
productizes these and ships them with the Xcode installation.

I know that it is a C/C++ Compiler, but how do I use it? Is it
Makefile based?

Does it replace GCC?

Both llvm-gcc and clang work as drop in replacements for GCC. They
take the same command line options etc, and are both quite usable on
the command line.

Can you provide advice on why Intel C++ compilers vs LLVM-GCC vs just normal GCC? Like benefits to one over the others? Pros and Cons, etc, etc...

Best,
-Jason

Thanks to Sam¡£
    As a fresh man on compiler, this mail helps me a lot :slight_smile:

Not really, I'm not very familiar with intel's C++ compiler. One obvious advantage of llvm-gcc is that it's free :slight_smile:

-Chris

My (possibly faultly) understanding is that intel's has good support
for numerics, presumably through auto-vectorization and such, but only
works for intel's architectures and is only excellent on intel chips.
llvm-gcc is a temporary thing until clang can compile llvm. GCC is
for when you don't want to use the llvm infrastructure, and just want
something easy to grab from the package manager.

In general, anyways.
~ Scott

My (possibly faultly) understanding is that intel's has good support
for numerics, presumably through auto-vectorization and such, but only

Yes, that's true.

works for intel's architectures and is only excellent on intel chips.

That used to be the case, but not so anymore. Intel compilers generate
just fine code for AMD processors. Since AMD doesn't produce their
own compilers, it's likely on par with any other vendor producing an
AMD compiler.

Well, except for Cray, that is. :slight_smile:

*ducks*

But hey, we use LLVM to do it!

                                      -Dave

"On par with any other vendor" doesn't count as "excellent", to me,
but fair enough.

Intel doesn't have the internal AMD designs so it can't make use of
proprietary knowledge as it can for Intel chips. But then, no AMD
compiler vendor can, so they're all operating on a level playing
field. That's all I meant. It is faster on some codes than other
AMD compilers. On other codes, it's slower. This is no different
than any other compiler.

                                  -Dave

Per Software optimization resources. C++ and assembly. Windows, Linux, BSD, Mac OS X, Intel's compiler doesn't use
vectorized codepaths on AMD chips by default; I don't know whether
that has changed in more recent versions.

-Eli

Hello David,

I just noticed your post and was wondering what Cray are doing with LLVM? Are
you using it in production?

I am trying to keep an eye on the fast moving LLVM project and like to keep up
to date with respect to its industrial applications...

Are there any papers in the works which benchmark some specification suite of C programs on GCC, LLVM-GCC, and CLANG?

The only stuff I have seen so far are some bar charts in a few LLVM presentations, would be nice to have something a little more comprehensive.

Cheers,

Granville

Trying to capture a notion of overall compiler optimization
in a representative set of benchmarks is a hard problem.
If you're interested in performance, it's best to measure it
on the applications you're interested in.

You should be suspicious of any one-dimensional analysis
of compiler optimization, especially if it's presented by
someone with an interest in a particular compiler.

Dan

We're on the LLVM users page, but that probably needs an update. I'll look at
checking something in.

The Cray X86 compiler is in use by customers today. The first release
happened in December with an update coming RSN. It's being used for real
science, today, on massively parallel supercomputers. We're talking tens of
thousands of processors.

So all you LLVM developers, put another feather in your cap. Our (yours and
Cray compiler devlopers') code is being used to solve the world's most
challenging and groundbreaking scientific problems!

                               -Dave

That's exactly right.

I have seen codes where even minor tweaks to a register allocation spilling
heuristic can have a 10-20% performance impact on X86. Compiler
transformations are often very sensitive to particular pieaces of code.

It's impossible to declare one compiler "better" than another because it's
likely the design goals of the compilers are quite different.

The great advantage of LLVM/Clang, in my mind, is its clean design and
relatively shallow learning curve. It's not only a smart business decision
to use the code because of its utilitarian value, it's smart from an
employee training perspective as well.

All IMHO, nothing I say here is an official Cray position, blah, blah,
blah. :slight_smile:

                             -Dave