Difference between LLVM, GCC 4.2 and Apple LLVM compiler 3.1

SundayMonday picture SundayMonday · Aug 18, 2012 · Viewed 7.4k times · Source

What are the major differences between LLVM GCC 4.2 and Apple LLVM compiler 3.1?

I'm fairly new to compilers so any help is appreciated. Also I'm especially interested in how the two compilers could affect game performance.

Answer

CodaFi picture CodaFi · Aug 18, 2012

The difference is a matter of both technology and speed.

CLANG was still young and buggy when Apple began the transition away from GCC's compiler and toolchain, so LLVM was built as a back-end to GCC to facilitate its eventual replacement. So, code went in and was compiled by GCC into some intermediate form, but was sent to LLVM to provide the final machine code and packaging.

Eventually, LLVM and especially CLANG were mature enough to replace GCC outright, which provided an amazing speed boost to compiling and a bump in the quality of the machine code output (though many argue that GCC still produces better quality code at the expense of speed).

But to address your concern about game performance: while CLANG may provide a "better" compile experience, performance is not the job of a compiler. While optimization and simplifications are a part of the compile process, the fact that people still write laggy games or produce infinite loops that lay waste to the stack show that performance is your job. The compiler can only do so much, the rest is up to you. The type or vendor of a compiler will also not make or break your game or affect frame rate or usability. You should read about lower-level optimizations for the ARM architecture. A few articles about NEON, and instruments would do you a lot more good than learning about "optimizing for the compiler".