ClangIR (CIR)
ClangIR is a high-level representation in Clang that reflects aspects of the C/C++ languages and their extensions. It is implemented using MLIR and occupies a position between Clang's AST and LLVM IR.
The project is incubated under LLVM's GitHub umbrella and is being upstreamed to the llvm-project (LLVM's official main repository).
GitHub incubator repo: llvm/clangir.
Check out the current status for updates and ClangIR in practice for a tool overview. Also see motivation and history for extra context about the project.
Talks and posts
- Jun 2025: Asia LLVM. ClangIR's Footprint: A quick compile-time impact report. video, pdf
- Mar 2025: Cambridge Computer Science Group Projects. Award on technical achievement. CUDA Support for ClangIR. video
- Nov 2024: Supercomputing Workshop. Introducing ClangIR, High-Level IR for the C/C++ Family of Languages. pdf
- Sep 2024: GSoC 2024: Compile GPU kernels using ClangIR
- Sep 2024: GSoC 2024: ABI Lowering in ClangIR
- Oct 2023: US LLVM Developers Meeting. Evolution of ClangIR: A Year of Progress, Challenges, and Future Plans. video, pdf.
RFCs
- January 2024: RFC: Upstreaming ClangIR
- June 2022: RFC: An MLIR based Clang IR (CIR)
Where to go from here?
Check out the docs for contributing to the project and dive into the CIR Dialect, list of CIR passes in Clang or the ClangIR pipeline.
Inspiration
ClangIR is inspired in the success of other languages that greatly benefit from a middle-level IR, such as Swift and Rust. Particularly, optionally attaching AST nodes to CIR operations is inspired by SIL references to AST nodes in Swift.
Last updated: Mon Aug 25 21:50:24 PDT 2025