LWN.net Logo

LFCS 2012: LLVM and Linux

LFCS 2012: LLVM and Linux

Posted Apr 26, 2012 3:18 UTC (Thu) by pr1268 (subscriber, #24648)
Parent article: LFCS 2012: LLVM and Linux

Interesting article. As someone who recently (two days ago) compiled and installed LLVM and Clang, I've been having fun lately rebuilding and benchmarking my own simple utilities (written in C or C++).

The short summary of my observation: Clang's compiled code runs slightly faster than GCC's (not to mention Clang code compiles faster), but the stripped ELFs are about the same size. Of course, I am aware that linking in pre-compiled libraries (e.g. glibc) means I'm including code outside the scope of Clang's compilation.

One weird Clang issue (I'll keep it brief): In a Mersenne Twister-based PRNG I've written, if I split a single source code .c file's two functions into their own files, and then recompile (separate .o files), then link everything together, my program doesn't run right (actually it doesn't run at all, but it appears to terminate normally). This only happens with Clang-compiled code (and only if I split the file's two functions into separate files), and not with GCC. Weird...

Regardless, I'm fascinated by the research and development emanating from the LLVM project. It'll be even more fun to see what's yet to come...


(Log in to post comments)

LFCS 2012: LLVM and Linux

Posted Apr 26, 2012 8:36 UTC (Thu) by juliank (subscriber, #45896) [Link]

Please note that clang is not always faster than GCC, and clang may perform some optimisations at -O2 that gcc only performs at -O3 (in my case, I have seen it inline non-static functions when compiling a complete program).

Clang has some better optimizations in some parts, gcc in others. Sometimes clang might also optimize less and thus cause smaller code, which might improve performance as well.

In general, performance should be roughly equally I'd say.

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds