See instructions on how to build clang with ClangIR support and checkout some examples.
The project is active, here's a list of the current supported pieces:
CIRGen: the process of generating CIR out of the Clang AST. We support a good set of functionality from C/C++, but there are many missing. The CIR/CodeGen test directory is a good proxy of the current supported features.
LLVM lowering: generating LLVM IR out of CIR. About 50% of all programs in llvm-testsuite/SingleSource
pass correctness checks.
MLIR in-tree dialect lowering: basically CIR -> MLIR dialects, initial support to memref and some other dialects but currently not as active as LLVM lowering.
Lifetime checker: implementation of a C++ lifetime checker (for catching C++ dangling pointers) based in C++ lifetime safety paper. Currently handles pointer/owner/aggregate type categories, lambda dangling references via captures and can also catch idiomatic cases of dangling references in coroutines coawait
expressions.
Check out our docs for contributing to the project and get a tour in the CIR Dialect.
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.
This project is part of the LLVM incubator, the source of truth for CIR is found at https://github.com/llvm/clangir.
The main branch contains a stack of commits, occasionally rebased on top of LLVM upstream, tracked in base branch.
Last updated: Mon Oct 21 14:06:09 PDT 2024