4 ms·
Thanks for the Discourse link. It has much more information. Quoting here for benefit of others; "Motivation In general, Clang’s AST is not an appropriate re
by rishav_sharan 4y ago
Thanks for the Discourse link. It has much more information.
Quoting here for benefit of others;
"Motivation
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 31 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++."
> Maybe because it's not "another IR for LLVM", but an IR for Clang?
AFAIK, Clang also uses LLVM IR.
- astrange 4y ago> AFAIK, Clang also uses LLVM IR. Clang doesn't use an IR for the frontend stuff; it emits AST straight to LLVM. It's built for speed and not very flexible. It can be difficult to see what some features like ObjC ARC are doing since there's no way to see an "intermediate" representation without debugging the compiler.