LLVM 13.0 pulls Flang into binary packages, fits debugger with MTE helpers

LLVM 13.0 pulls Flang into binary packages, fits debugger with MTE helpers

Compiler infrastructure project LLVM is now available in version 13.0

The freshly pushed out major release is the first to include Fortran frontend Flang in its binary packages, and it provides an option to use its build system for the creation of multiple distributions. LLVM’s intermediate representation was meanwhile fitted with an opaque pointer type ptr (which is in its early stages however, so not fit for general use yet) and a mandatory type field for its inalloca attribute.

While most targets seem to have stayed untouched, the project’s C API underwent quite a few changes leading up to the release. Developers can now change alignment on atomicrmw and cmpxchg instructions, call into the new pass manager, or make use of type attributes in LLVM-C. 

The LLVM team also worked on letting the API play nicely with the ORCv2 modular API for building JIT compilers. As a result there’s support for dumping objects from the on-request compiler, creating custom MaterializationUnits and APIs to retrieve an LLJIT instance’s linking layers, and adding ORCv2 object buffers to an object layer. 

Users of the API should be aware of some breaking changes, like an additional argument called LLVMBool CanThrow in LLVMGetInlineAsm, and a changed order of the function pointer’s arguments in LLVMOrcObjectTransformLayerTransformFunction.

A quite popular component of the LLVM project is LLDB. The debugger is the default option in Apple’s IDE for macOS Xcode and is now included in LLVM binaries. Its latest iteration mainly helps developers working with AArch64 architectures, since it provides support for AArch64 SVE register access, pointer authentication, and debugging programs on AArch64 Linux that use memory tagging (MTE). 

LLDB also learned memory tag read and memory tag write commands, recognises MTE enabled regions via memory region as well as synchronous and asynchronous tag faults, and there are MTE annotations to complement the fault address should a sync tag fault appear.

As usual, the LLVM release is accompanied by a new version of compiler frontend Clang. The team behind the project highlights support for guaranteed tail calls via statement attributes [[clang::musttail]] in C++ and __attribute__((musttail)) in C as the main feature of v13. Its addition is said to help raise an error “if a tail call cannot be guaranteed, for example if the function signatures of caller and callee are not compatible”.

Other enhancements to Clang include compiler flags that emit warnings when reserved identifiers are incorporated in user code, parameters or variables are set but not used, or when subtraction involving a null pointer would lead to undefined behaviour. Version 13.0 also extends OpenMP support, so users can work with the loop transformation directives from v5.1, and it understands C++11-style [[]] attributes on using– declarations.