ClangIR has been in development for a number of years now as a new intermediate representation for the Clang compiler. ClangIR makes use of MLIR and is higher-level than LLVM IR. With ClangIR able to preserve more C/C++ source semantics, its usage can lead to better diagnostics, code/static analysis, and more performance optimizations compared to everything lowered straight away from AST to LLVM IR. While not enabling its usage by default, LLVM stakeholders are discussing at least now building it by default. There is now an LLVM Discourse thread to discuss the pros and cons of enabling ClangIR building by default. There is also this RFC pull request that would enable its building by default in the LLVM source tree when compiling Clang. ClangIR is already upstreamed but has refrained from being part of the default build configuration. In building ClangIR, MLIR in turn becomes a default Clang dependency. On the downside is that ClangIR+MLIR by default will significantly increase the build time of compiling Clang itself. Some estimates put the build times more than doubling. ClangIR also lacks a "Microsoft" target for targeting Windows, continuous integration (CI) testing will also be longer due to ClangIR testing, and other related concerns. Again, this current proposal is just about building ClangIR by default with Clang but not using it by default and in turn no code generation changes by default. On capable builds, the -fclangir compiler flag is needed for enabling ClangIR usage. In addition to the greater optimizations and static analysis and diagnostics benefits of ClangIR,the MLIR-based ClangIR does open up more doors moving forward for GPU/device offload with better lowering of code to SPIR-V/Vulkan and similar MLIR multi-device benefits. We'll see what comes of this discussion for building it by default.
LLVM Developers Discuss Enabling ClangIR Build By Default
Full Article
Original Source
Read the full article at Phoronix →KhanList aggregates and links to publicly available news content. We do not host full articles from third-party sources. Always verify important information with original sources.