Meta Developing A New IR For LLVM's Clang C/C++ Compiler With Better Speed, Security

Written by Michael Larabel in LLVM on 21 June 2022 at 05:28 AM EDT. 6 Comments
LLVM --
Meta (Facebook) engineers on Monday announced CIR, a proposed new intermediate representation (IR) for LLVM's Clang C/C++ compiler front-end that is based on the MLIR representation.

CIR is their new IR that is short for "Clang IR" or "C/C++ IR" and is another open-source effort out of Meta/Facebook that they are hoping to eventually upstream. They hope this new IR for Clang will lead to improved diagnostics for modern C++ programming, allow for more C++ high level optimizations, and addressing other shortcomings with Clang's AST / LLVM IR. Inspired by Swift's SIL and Rust's HIR/MIR intermediate representations, Meta hopes CIR could provide similar improvements for C++ programmers.

Among the defined goals for CIR is to provide better diagnostics for correctness / security / performance. This could ultimately lead to safer C++ programs. It was noted in the CIR announcement, "Security / Bugs: The Google Chrome team notes that around 70% of their high-severity security bugs are memory unsafety problems. Half of which are use-after-free bugs. Using std::optional to illustrate, CIR could introduce instructions for optional derefs (cir.std.optional.deref) and diagnose them as harmful if they are not dominated by the check on whether the object contains a value (cir.std.optional.has_value)."


Those interested in learning more about CIR can visit the LLVM Discourse announcement. The CIR code and documentation in current form is hosted by Facebook Incubator on GitHub.

LLVM founder Chris Lattner already commented on the CIR effort, multiple times mentioning he's a "superfan" of this effort. He's also hoping for it to become an LLVM incubator project and getting more LLVM developers working on this code and ultimately as an upstream solution.

CIR is going to definitely be another interesting LLVM effort to watch for improving this leading open-source compiler stack.
Related News
About The Author
Author picture

Michael Larabel is the principal author of Phoronix.com and founded the site in 2004 with a focus on enriching the Linux hardware experience. Michael has written more than 20,000 articles covering the state of Linux hardware support, Linux performance, graphics drivers, and other topics. Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and OpenBenchmarking.org automated benchmarking software. He can be followed via Twitter, LinkedIn, or contacted via MichaelLarabel.com.

Popular News This Week