My name is Lang Hames, and I am a PhD student at the University of Sydney where I research aggressive register allocation techniques. Last year I completed a six month internship with the LLVM team improving their register allocation infrastructure, and last month Google sponsored my attendance at the 2010 LLVM Developers’ Meeting.
I had a fantastic time at the meeting. Californian hospitality always makes me feel right at home, and it was great to see all my friends from previous Dev Meetings and my internship with the LLVM team.
The meeting was huge this year, with over 190 attendees and such a abundance of talks it was impossible to make it around to everything on the day. It's a good thing the entire proceedings are up on the web. The talks this year were impressive and diverse, including introductions to major new LLVM-family projects, new applications leveraging LLVM technology, and targets ranging from GPUs to FPGAs.
A few of my favourite talks:
Doug Gregor, a member of the Clang team at Apple and code owner of the Clang libraries, gave a great talk on "libclang: Thinking Beyond the Compiler.” (PDF) libclang is the Clang compiler's functionality packaged as a library. It lets you parse source, access diagnostics, examine ASTs and even find code completion targets. This raises the really exciting prospect of building new development tools on top of a feature complete front-end. Imagine having syntax highlighting, code-completion and cross-reference all handled by the same parser that's in the compiler. It's difficult to over-state how cool this is, and I say that as an optimization guy (I thought the front end was just there to feed me CFGs). I'd highly recommend checking out a copy of Clang and playing with it. Doug's talk included plenty of code snippets, and I've found reading through them to be a great way to get started.
Craig Silverstein of Google gave a talk on "Implementing Include-what-you-use Using Clang” (PDF). Include-what-you-use is the principle that C/C++ source files should directly #include header files that provide declarations/definitions that they use, rather than relying on transitive #includes. Building on Clang, Craig has developed a tool to analyse C++ code to detect and correct violations of this principle. This looks like a really handy and great example of what you can build on top of libclang.
Howard Hinnant of Apple introduced us to libc++ (PDF), a new C++ standard library built from the ground up with C++0x in mind. It has a lot of cool features, including fast default constructors, minimal memory footprints for default constructed objects, and fast move constructors. Dependence on libstdc++ is no barrier to trying it out: you can happily link your project against both libraries (libc++ uses inline namespaces to avoid confusion over ABI incompatible objects). One feature I thought was particularly neat was the adaptive sort: the sorting algorithms in libc++ automatically recognize partially sorted ranges and optimize their behavior to exploit the partial sorting for better performance. Howard's test cases showed impressive speedups (over 2x in a lot of cases). I'm really looking forward to trying this out in some of my code.
Greg Clayton, also of Apple, introduced LLDB (PDF), a debugger built on Clang and LLVM libraries. This looks incredible and deserves a blog post of its own, but I'll mention a few of my favorite features here. By building on libclang, LLDB is able to parse complex C++ expressions, up to and including multi-line expressions with local variables and control flow. It has been built from scratch to support a multicore, multithreaded world, with per-thread state and runtime control. Symbolic breakpoints allow you to set breakpoints with everything from File and Line to regular expressions (great for breaking on getters, setters, handlers, etc). Finally, following LLVM's design philosophy all this functionality will be available via a C-API, with python bindings provided too. Looks like another excellent base for new developer tools, and I can't wait to see what people do with it.
Other talks I particularly enjoyed included Nadav Rotem's talk (PDF) on using LLVM for C-to-Verilog synthesis (aka building circuits out of C-code). Nadav ran us though some of the optimizations necessary to prepare LLVM IR for efficient hardware synthesis. Xuejun Yang's talk, "Hardening LLVM with Random Testing" (PDF), was also fantastic. Xuejun's team have developed a system for generating expressive, unambiguous C programs with defined meanings which can be used to test compiler correctness. Since March, 2008 they've helped find and fix over 170 bugs in LLVM.
Slides and videos of the talks I mentioned, and many others, are available on the LLVM Dev Meeting 2010 website. I highly encourage you to check them out.
The Dev Meeting doesn't stop at the talks of course. It's an invaluable opportunity to meet and swap ideas with other LLVM developers. I got a chance to meet Jakob Olesen and Andy Trick, who have been doing great things with LLVM's register allocation framework (my PhD research area). I also chatted with some of the Google devs who are using Clang to tackle issues such as include-what-you-use in the Google codebase. Finally I attended “Birds of a Feather” meetings on LLVM optimizations, and on the progress that's been made (and plans for the future) in building Linux with Clang.
Many thanks to Google, Apple, Qualcomm, and the Qualcomm Innovation Center for making such an amazing event possible. I'd also like to add very special thank you to Google for sponsoring me to attend this event. At the end of the day I walked out amazed at what has been achieved in the last year, and how active the LLVM community has been. I look forward to trying out all these new tools for myself, and I can't wait for next year!
By Lang Hames, LLVM Developer