I don't know if its the right place to ask this question. But why did Apple choose to use llvm and its clang implementation to code for OpenCL/OpenGL?? What benefits did it bring to them and how? Excuse my ignorance on this topic, I know not much about this.

3 Answers
3

Apple created Clang as a drop in replacement to GCC for C/C++/ObjC and ObjC++. The creator of LLVM works at Apple inside their compiler divisions. In a joint effort with the University of Illinois who hosts the projects Apple has created complete replacements for GCC, GDB [see LLDB], libstdc++ [see libc++] and several new projects.

The GPLv3 was the final straw that ended Apple's interest in contributing to GCC which is the reason Apple ended it at GCC 4.2.x.

Runtime code specialization within the fixed-function vertex-processing
pipeline. Basically, the OpenGL pipeline has many parameters (is fog
enabled? do vertices have texture info? etc) which rarely change:
executing the fully branchy code swamps the branch predictors and
performs poorly. To solve this, the code is precompiled to LLVM .bc
form, from which specializations of the code are made, optimized,
and JIT compiled as they are needed at runtime.

OpenGL vertex shaders are small programs written using a family of
programming langauges with highly domain-specific features (e.g. dot
product, texture lookup, etc). At runtime, the OpenGL stack translates
vertex programs into LLVM form, runs LLVM optimizer passes and then JIT
compiles the code.

Because they contribute to the develop of Clang/LLVM and because source code compiled with LLVM/Clang produce faster binary than GCC ...

Clang's developers claim that it provides reduced memory footprint and
increased compilation speed compared to competing compilers, such as
GCC. To support their claim, they present that, as of October 2007,
Clang compiled the Carbon libraries well over twice as fast as GCC,
while using about one-sixth GCC's memory and disk space.

This is about the compilation speed, not the resulting code speed. Clang is much faster than GCC (at least for C++), and it is much more hackable (i.e., it is easier to add OpenCL support), but it is still producing a slightly slower code than GCC, not all the optimisations are tuned to a same degree of perfection yet.
–
SK-logicOct 23 '12 at 9:11