Yesterday, the LLVM team announced the stable release of LLVM 9; though LLVM 9.0 missed its planned release date, which was 28th August. LLVM 9.0 RC3 was made available earlier this month. With LLVM 9, the RISC-V target is now out of the experimental mode and turned on by default. Other changes include improved support for asm goto in the MIPS target, another assembly-level support added to the Armv8.1-M architecture, new immarg parameter attribute added to the LLVM IR, and more. LLVM 9 also explores many bug fixes, optimizations, and diagnostics improvements. LLVM 9 also presents an experimental support for C++ in Clang 9.
What’s new in LLVM 9
- Two new extension points, called EP_FullLinkTimeOptimizationEarly and EP_FullLinkTimeOptimizationLast are available as plugins for specializing the legacy pass manager full LTO pipeline.
- A new COFF object files/executables support for llvm-objcopy/llvm-strip. It will support the most common copying/stripping options.
- LLVM_ENABLE_Z3_SOLVER has replaced the CMake parameter CLANG_ANALYZER_ENABLE_Z3_SOLVER.
- LLVM 9.0 has finally made the “experimental” RISC-V LLVM backend “official” and will be enabled by default. This means that it no longer needs to be enabled by LLVM_EXPERIMENTAL_TARGETS_TO_BUILD. The RISC-V Target has full codegen support for the RV32I and RV64I based RISC-V instruction set variants, along with the MAFDC standard extensions.
Explaining the reason behind this update, Alex Bradbury, CTO and Co-Founder of the lowRISC said, “As well as being more convenient for end users, this also makes it significantly easier for e.g. Rust/Julia/ Swift and other languages using LLVM for code generation to do so using the system-provided LLVM libraries. This will make life easier for those working on RISC-V ports of Linux distros encountering issues with Rust dependencies.”
- A new support for target-independent hardware loops is added along with PowerPC and Arm implementations, in IR.
Other changes in LLVM 9
LLVM IR: A new immarg parameter attribute is added. It indicates that an intrinsic parameter is required to be a simple constant. The atomicrmw xchg now allows floating point types and supports fadd and fsub.
ARM Backend: A assembly-level support is added for the Armv8.1-M architecture, including the M-Profile Vector Extension (MVE). Another pipeline model to be used for cores is also added to Cortex-M4.
MIPS Target: Improved experimental support for GlobalISel instruction selection framework. New support for .cplocal assembler directive, sge, sgeu, sgt, sgtu pseudo instructions and asm goto constraint.
PowerPC Target: Improved handling of TOC pointer spills for indirect calls and better precision of square root reciprocal estimates.
SystemZ Target: A new support for the arch13 architecture is added. The builtins for the new vector instructions can be enabled using the -mzvector option.
What’s new in Clang 9?
With the stable release of LLVM 9, Clang 9 official release was also made available. The major new feature in Clang 9 is the new addition of experimental support for C++ for OpenCL. Clang 9 also new compiler flags- -ftime-trace and ftime-trace-granularity=N.
C Language improvements in Clang 9
The __FILE_NAME__ macro is added as a Clang specific extension and supports all C-family languages. It also provides initial support for asm goto statements for control flow from inline assembly to labels. The main consumers of this construct are the Linux kernel (CONFIG_JUMP_LABEL=y) and glib. Also, with the addition of asm goto support, the mainline Linux kernel for x86_64 is now buildable and bootable with Clang 9.
C++ Language improvements in Clang 9
An experimental support for C++is added to OpenCL. Clang 9 also brings backward compatibility with OpenCL C v2.0. Other implemented features include:
- The address space behavior is improved in the majority of C++ features like templates parameters and arguments, reference types, type deduction, and more.
- OpenCL-specific types like images, samplers, events, pipes, are now accepted
- OpenCL standard header in Clang can be compiled in C++ mode
Users are happy with the LLVM 9 features, especially the support for asm goto.
A user on Hacker News comments, “This is big. Support for asm goto was merged into the mainline earlier this year, but now it’s released . Aside from the obvious implications of this – being able to build the kernel with LLVM – working with eBPF/XDP just got way easier”
Another user says, “The support for asm goto is great for Linux, no longer being dependent on a single compiler for one of the most popular ISAs can only be a good thing for the overall health of the project.”
For the complete list of changes, check out the official LLVM 9 release notes.