DragonEgg 3.0 Puts GCC & LLVM In One Bed

Written by Michael Larabel in Software on 5 December 2011 at 04:00 AM EST. Page 1 of 5. 11 Comments.

LLVM 3.0 was released last week as a major update to this increasingly popular open-source compiler infrastructure. With the release of LLVM 3.0 proper also came major updates to the Clang C/C++ compiler front-end and the DragonEgg GCC plug-in (here are the exciting LLVM3 changes). In this article is a look at DragonEgg for LLVM 3.0 that plugs into GCC to replace its optimizers and code generators with those from LLVM.

The DragonEgg plug-in is not new to LLVM 3.0, but it has been around for quite a while. The DragonEgg plug-in has matured a lot in the past year and is in rather great shape for LLVM 3.0. Last November was when I published the first DragonEgg benchmarks and compared the performance to that of native GCC, LLVM-GCC, and Clang.

With the LLVM 3.0 release, DragonEgg succeeds LLVM-GCC, which was the modified version of the GNU Compiler Collection that used various Low-Level Virtual Machine components internally. With GCC's plug-in support on newer versions of the Free Software Foundation compiler, much of this can be moved to a plug-in that works on an unmodified version of GCC. This makes it easier to switch between a vanilla GCC and that with the LLVM generators/optimizers, is easier to maintain, allows using the latest GCC releases, etc. LLVM-GCC was also using the GCC 4.2 code-base due to licensing differences. Previous versions of DragonEgg did require a small patch to LLVM itself, but now the new version of DragonEgg will work with vanilla versions of GCC 4.5/4.6 and future releases.

DragonEgg with GCC can be useful in cases where LLVM's Clang native C/C++ front-end does not correctly compile the target software, there is other software dependence on GCC, or wishing to compile a language that currently doesn't have a native compiler front-end to LLVM. DragonEgg is currently targeted for x86 and x86_64 architectures. The languages fully supported by the GCC-with-LLVM plug-in include C, C++, ADA, and Fortran. There is also partial DragonEgg support for the Java, Go, Objective-C++, and Objective-C languages. Supported operating systems for using this plug-in are currently Linux, Darwin, and FreeBSD.

Besides now working with mainline GCC 4.5/4.6 with no patches, the type and constant conversion logic has been almost entirely rewritten and the "-fplugin-arg-dragonegg-enable-gcc-optzns" option is largely improved. Passing the "-fplugin-arg-dragonegg-enable-gcc-optzns" option to the compiler results in both the GCC and LLVM optimizers being used when generating binaries. This DragonEgg option is intended to deliver the "ultimate performance", but with the 3.0 release, it is still deemed experimental and in some cases is known to crash the plug-in. This compiler optimization switch will also be illustrated in today's benchmarks.


Related Articles