LLVM Project Blog

LLVM Project News and Details from the Trenches

Sunday, February 21, 2010

Dragonegg Successfully Self-Hosts!

The dragonegg GCC plugin can host itself! Dragonegg lets you use the LLVM optimizers with GCC-4.5, much like llvm-gcc, but unlike llvm-gcc does not involve modifying GCC, thanks to the new GCC plugin infrastructure (currently one small patch is required). We built all of GCC-4.5, LLVM and dragonegg with dragonegg, then used the resulting binaries to build them all again. Why? Because we love to build! And because this was a great way of checking that nothing was miscompiled. The final dragonegg plugin was fully functional, successfully passing the entire dragonegg test suite.

Thursday, February 4, 2010

Clang Successfully Self-Hosts!

Today, Clang completed its first complete self-host! We built all of LLVM and Clang with Clang (over 550k lines of C++ code). The resulting binaries passed all of Clang and LLVM's regression test suites, and the Clang-built Clang could then build all of LLVM and Clang again. The third-stage Clang was also fully-functional, completing the bootstrap.

Congratulations to all of the Clang developers on this amazing achievement!

Wednesday, January 6, 2010

The x86 Disassembler

Disassemblers make binary analysis work. With a reliable disassembler, you can solve high-level problems like tracing back through a program's call stack or analyzing sample-based profiles to low-level problems like figuring out how your compiler unrolled a tight floating-point loop or what advantages declaring a variable const actually had at the other end of the optimization chain. A reliable disassembler, which takes sequences of bytes and prints human-readable instruction mnemonics, is a crucial part of any development platform. You're about to go on a whirlwind tour of the LLVM disassembler: why one should exist, what's great about this one, and how you can use it.

Sunday, January 3, 2010

Address of Label and Indirect Branches in LLVM IR

The GCC Compiler supports a useful "Label as Values" extension, which allows code to take the address of a label and then later do an unconditional branch to an address specified as a void*. This extension is particularly useful for building efficient interpreters.

LLVM has long supported this extension by lowering it to a "correct" but extremely inefficient form. New in LLVM 2.7 is IR support for taking the address of a label and jumping to it later, which allows implementing this extension much more efficiently. This post describes this new LLVM IR feature and how it works.

Thursday, December 24, 2009

Clang Builds LLVM

Just in time for the Christmas holiday, the Clang project has hit a major milestone: Clang can now build all of LLVM and Clang!

The resulting Clang-built-Clang is not yet functional, so this "self-build" milestone is well short of full self-hosting. However, self-building indicates that C++ parsing, semantic analysis, and code generation is solid enough to compile the entirety of LLVM (~350k lines of C++ code) and Clang (~200k lines of C++ code) and produce object files that link together properly. To get to this point, we've fixed many bugs in Clang (when compiling C++ code), but also several bugs in LLVM and Clang that were found by Clang itself.

We are tracking a number of Clang bugs that manifest when building LLVM and Clang, as we make our way to the next big milestone: full self-hosting of Clang!

Saturday, December 19, 2009

Advanced Topics in Redundant Load Elimination with a Focus on PHI Translation

In our previous post on GVN we introduced some basics of load elimination.  This post describes some advanced topics and focuses on PHI translation: what it is, why it is important, shows some nice things it can do, and describes the implementation in LLVM.

Friday, December 18, 2009

The Dreaded Two-Phase Name Lookup

C++ has more than its fair share of dark, dank corners, especially where templates are concerned. One of the most vexing is "two-phase name lookup", which involves lookup for any names that occur in the body of a template. As you might expect, there are two different phases of templates: