Announcing LLILC: An LLVM based compiler for dotnet CoreCLR.

The LLILC project (we pronounce it “lilac”) is a new effort started at Microsoft to produce MSIL code generators based on LLVM and targeting the open source dotnet CoreCLR (GitHub - dotnet/coreclr: CoreCLR is the runtime for .NET Core. It includes the garbage collector, JIT compiler, primitive data types and low-level classes.). We are envisioning using the LLVM infrastructure for a number of scenarios, but our first tool is a Just in Time(JIT) compiler for CoreCLR. This new project is being developed on GitHub and you can check it out at https://github.com/dotnet/llilc.

  • Why a new JIT for CoreCLR?

While the CoreCLR already has a JIT, we saw an opportunity to provide a new code generator that has the potential to run across all the targets and platforms supported by LLVM. To enable this, as part of our project we’re modifying an MSIL reader that operates directly against the same common JIT interface as the production JIT (RyuJIT). This new JIT will allow any C# program written for the .NET Core class libraries to run on any platform that CoreCLR can be ported to and that LLVM will target.

*Are we planning to do Ahead of Time compilation?

Yes. The roadmap for the project includes an AOT tool but we’re still getting our plans together. There is more detail on this part of the project on the wiki.

  • Managed code in LLVM

We’ve been having a great experience with LLVM and it’s been super-fast to get the JIT up and running. There are 3 areas we will need to be expanding support for in LLVM: managed code centric optimizations, precise garbage collection, and exception handling. Each one of these areas has a broader treatment on the wiki but briefly we intend to help bring:

  • Optimization of implicit runtime checks that support type safety in C#.

  • Precise garbage collection (we’re building on the statepoint design that’s currently being added to LLVM)

  • Exception handling semantics for C#

  • What’s working?

Today on Windows we have the MSIL reader & LLVM JIT implemented well enough to compile a significant number of methods in the JIT bring up tests included in CoreCLR. In these tests we compile about 90% the methods and then fall back to RyuJIT for cases we can’t handle yet. The testing experience is pretty decent for developers. The tests we run can be seen in the CoreCLR test repo.

Please check out our wiki for more info. (Home · dotnet/llilc Wiki · GitHub)

Thanks,

Russell

This is really cool! +CC Philip and Sanjoy who have been quite active lately upstream on improving LLVM for this sort of use case.

– Sean Silva