Engage! LLVM 12 gets ready for next-gen processors

LLVM 12

Compiler infrastructure project LLVM 12 is now available for downloading. The release comes more than a month later than expected due to some show stopping bugs but seems to be worth the wait for those working with x86 or PowerPC architectures.

LLVM’s compiler and toolchain tech is currently used in compilers for all sorts of languages such as Rust, Kotlin, CUDA, and Julia, so careful testing is mandatory for the project. 

Last year pressure on the LLVM team became apparent when various language developers took to the internet to share their frustration about performance degradations introduced by a version update. 

Version 12 is the first to introduce support for Intel’s next generation processors Alder Lake and Sapphire Rapids as well as AMD Zen 3 and x86-64 micro-architectures, which might be the most interesting additions for projects hoping to get in on these early or simply speed up. 

To match the behaviour of GCC, new function attribute tune-cpu has been added to apply microarchitectural optimisations independent from the target-cpu attribute or TargetMachine CPU which will be used to select Instruction Set. LLVM now also knows how to work with HRSET, UINTR, and AVXVNNI instructions and pseudo-prefixes to control displacement sizes for memory operands and jump displacements. 

Meanwhile the PowerPC target was fitted with improvements to loop unroll-and-jam, PartialInliner, PGO, and CodeGen, which can now help those targeting POWER10. Devs looking to compile something for the AIX operating system should see improvements thanks to the added compiler -rt support, code generation for C++ dynamic initialisation and finalisation of non-local variables, and better pragma support.

Extra effort was also put into making LLVM work better in Windows environments. The AArch64 backend for example was fitted with improvements to make unwind data more compact, bringing down its size by around 60 per cent when compared to LLVM 11. The new release is also said to produce “proper assembly output” for the Windows target, which should help in getting the output into a usable form.

LLVM’s intermediate representation now includes a byref attribute to better represent argument passing for the calling conventions of the AMD GPU kernel and a type parameter in the sret attribute. Vector reduce intrinsics have matured since the last release, which is why they no longer have an experimental in their name.

LLVM 12 is accompanied by a new version of the Clang C/C++/Objective-C frontend, which sees the project improve its diagnostics, C++20, and Windows support. Clang also comes with new compiler flags to specify the targeted binutils version and enable calls to helper functions implementing atomic operations. Details can be found in the tool documentation.