LLVM is a set of reusable compiler components that provide building blocks for creating compilers and related tools.  In Red Hat Enterprise Linux (RHEL), these components are used in the Rust compiler, embedded shader compiler in Mesa, and BPF tools like BCC and bpftrace. In addition, LLVM itself comes with it's own C/C++ compiler (Clang) and linker (LLD) which are also a part of RHEL.

The upstream project for LLVM is very large and moves quickly with almost 100 commits per day and over 250 unique contributors per month. In addition to building and packaging the LLVM sources for RHEL, Red Hat engineers are actively engaged in the upstream community working hard to make the project better.  Here is what Red Hat has been doing with LLVM in the past year.

LLVM Foundation Board of Directors

The LLVM Foundation is a non-profit organization that oversees the non-technical aspects of the LLVM project in addition to doing education and outreach within the field of compiler and tools. There is a nine-person Board of Directors that oversee the foundation, and I currently am a member as well as Secretary for the Board.  

Red Hat supports my foundation work as part of my day job,  and my participation in the foundation involves attending board meetings, helping with project infrastructure, and resolving some non-technical issues for the project.  

LLVM Release Management

In addition to serving on the Board, I also serve as the release manager for the project. LLVM has a 6-month release cycle which includes a major release (X.0.0) plus one follow on bug fix release (X.0.1) in each cycle. I’m responsible for overseeing the release process and ensuring that bugs get fixed and that the releases are stable. We also have several engineers at Red Hat that contribute to the release process by fixing bugs and testing builds.

Long-Term Redesign: Opaque Pointers

LLVM uses an internal compiler representation called LLVM IR.  LLVM-based compilers produce this intermediate representation and hand it off to the LLVM components so they can optimize it and generate machine code. LLVM IR is well-defined and is always improving and adding new features. One of these improvements that the community is working on is known as Opaque Pointers.

Opaque Pointers are pointers without an associated type. Currently in LLVM IR each pointer

records the type of the value being pointing to, so you can have an i8* that points to an i8 value, an i32* that points to 32-bit value, etc.

Dropping the pointer type will simplify the IR by eliminating the need to cast between pointer types (a very common operation). This in turn will help reduce the complexity of the optimizer and should make it run faster and better.  Red Hat is contributing to this effort upstream by helping to move various optimizer passes and other parts of LLVM to this new kind of pointer representation.  

Compile Time Improvements

 At Red Hat, we’ve been working on a number of improvements to LLVM’s internal data structures to help improve the compiler speed.  Compiler speed (i.e. how long it takes a compiler to compile a program) can sometimes be overlooked as most users tend to focus on and ask for faster execution (i.e. how long it takes a program to run).  However, compiler speed is very important to developers, and improving compiler speed can help developers do their work faster. 

In addition to all the things mentioned above, Red Hat developers have also been:

  • Adding new buildbots to LLVM’s CI infrastructure.

  • Helping to improve the usability of LLVM tools with more clear help messages.

  • Contributing to Clang’s OpenCL C implementation.

  • Creating nightly snapshot builds for the community to use.

  • Improving security features.

  • Fixing Bugs!

These contributions along with others from the community are planned to be available either in current or future RHEL releases.  We package a new version of LLVM in each RHEL minor release, so the latest features and bug fixes are always available to RHEL users.

At Red Hat, we have an “Upstream First” policy.  We understand that healthy upstream projects lead to better products for our customers and developers.  This is why we have been very active in the upstream LLVM project for not just 2021 but previous years as well.  We have some exciting plans for LLVM in 2022 and are looking forward to continuing to work with this amazing community.


執筆者紹介