4 ms·
https://discourse.llvm.org/t/rfc-an-mlir-based-clang-ir-cir/63319 https://discourse.llvm.org/t/rfc-an-mlir-based-clang-ir-cir/... : > Our current (and initial)
by stefantalpalaru 4y ago
https://discourse.llvm.org/t/rfc-an-mlir-based-clang-ir-cir/63319 https://discourse.llvm.org/t/rfc-an-mlir-based-clang-ir-cir/... :
> Our current (and initial) goal is to provide a framework for improved diagnostics for modern C++, meaning better support for coroutines and checks for idiomatic uses of known C++ libraries.
...
> In general, Clang’s AST is not an appropriate representation for dataflow analysis and reasoning about control flow. On the other hand, LLVM IR is too low level — it exists at a point in which we have already lost vital language information (e.g. scope information, loop forms and type hierarchies are invisible at the LLVM level), forcing a pass writer to attempt reconstruction of the original semantics. This leads to inaccurate results and inefficient analysis - not to mention the Sisyphean maintenance work given how fast LLVM changes. Clang’s CFG is supposed to bridge this gap but isn’t ideal either: a parallel lowering path for dataflow diagnostics that (a) is discarded after analysis, (b) has lots of known problems (checkout Kristóf Uman’s great survey 28 regarding “dataflowness”) and (c) has testing coverage for CFG pieces not quite up to LLVM’s standards.
> We also have the prominent recent success stories of Swift’s SIL and Rust’s HIR and MIR. These two projects have leveraged high level IRs to improve their performance and safety. We believe CIR could provide the same improvements for C++.