Release of the LLVM 22 compiler suite

After six months of development, LLVM 22.1.0 has been released. It develops tools (compilers, optimizers, and code generators) that compile programs into intermediate bitcode of RISC-like virtual instructions (a low-level virtual machine with a multi-level optimization system). The generated pseudocode can be converted into machine code for a given target platform or used by a just-in-time (JIT) compiler to generate machine instructions directly during program execution. Based on LLVM technologies, the project is developing the Clang compiler, supporting the C, C++, and Objective-C programming languages. Starting with the 18.x branch, the project switched to a new version numbering scheme, according to which release 0 ("N.0") is used during development, and the first stable version is numbered "N.1."

Improvements in Clang 22 include:

  • Added support for memory allocation tokens (Allocation Tokens) for marking memory allocation operations performed using functions such as malloc with a unique identifier. Allocation tokens allow for structuring heap information, simplifying memory leak detection, and enabling grouping of objects based on their purpose or modification patterns (e.g., separating "hot" from "cold" data). To enable, use the "-fsanitize=alloc-token" flag.
  • Features related to the C language:
    • A draft specification defining the "defer" deferred execution mechanism has been implemented, allowing actions to be executed when the current scope exits. The "-fdefer-ts" flag has been added to enable "defer" support.
    • The built-in function __builtin_stack_address() has been added, mirroring the similar function in GCC. This function returns the stack address separating the stack area of ​​the current function that called __builtin_stack_address() and subsequent functions it calls.
  • Capabilities being developed for the future C2y standard:
    • Added support for named loops, which allows you to assign names to loops and switch statements, which can be specified in break and continue statements to explicitly define the loop to exit from. outer: for (int i = 0; i < IK; ++ i) { for (int j = 0; j < JK; ++ j) { continue; // go to CONT1 continue outer; // go to CONT2 // CONT1 } // CONT2 }
    • The implementation of the built-in "__COUNTER__" macro, designed to generate unique identifier names, has been expanded and included in the standard. A limit of 2147483647 calls to this macro has been set; exceeding this limit will generate an error.
    • Removed warning (-Wstatic-in-inline) when using static functions or variables inside functions declared as "extern inline".
  • Capabilities defined in the C23 C standard:
    • The float.h header file now supports the FLT_SNAN, DBL_SNAN, and LDBL_SNAN macros, which implement signaled (causing an exception when used in arithmetic operations) NaN values ​​for float, double, and long double types.
    • Fixed a bug where different unnamed types were treated as compatible within the same translation unit if they had the same fields.
    • The "-MG" flag used to ignore missing header files during dependency scanning has been extended to "#embed" directives and now suppresses the "file not found" error when a file specified in a "#embed" directive is missing.
  • C++ related features:
    • The ability to use structured bindings in the "constexpr" context, as developed in the C++2c (C++26) specification, has been added. This means that references to constant expressions can now themselves be constant expressions. Support is implemented for arrays and simple structures (tuples are not yet supported). constexpr int arr[] = {1, 2}; constexpr auto [x, y] = arr;
    • As required by the C++20 standard, constraints are now converted to standard form before being checked, allowing for more accurate diagnostic messages and proper handling of substitution errors in template arguments used only in concept-ids.
    • Added a family of built-in functions "__builtin_[lt|gt|le|ge]_synthesizes_from_spaceship" to find out whether the comparison operators "<", ">", "<=", and ">=" were synthesized from the "<=>" operator.
    • The "-Wincompatible-pointer-types" parameter has been changed to output an error instead of a warning. To revert to the previous behavior, use the "-Wno-error=incompatible-pointer-types" option.
  • Added built-in functions __builtin_bswapg, __builtin_elementwise_ldexp, __builtin_elementwise_fshl, __builtin_elementwise_fshr, __builtin_elementwise_minnumnum, __builtin_elementwise_maxnumnum, __builtin_masked_load, __builtin_masked_expand_load, __builtin_masked_store, __builtin_masked_compress_store, __builtin_masked_gather, __builtin_masked_scatter, and __builtin_dedup_pack. For example, builtin_dedup_pack allows you to remove duplicates from a list of types: using MyTypeList = TypeList<__builtin_dedup_pack …>; // the resulting type will be TypeList
  • When debugging undefined behavior with UBSan (-fsanitize=undefined -fsanitize-trap=undefined), error cause information is now included in the generated debug information. The "-fsanitize-debug-trap-reasons" flag has been added to specify the level of detail in error information. It can be set to "basic" for general descriptions (e.g., "Integer addition overflowed") and "detailed" to include detailed information (e.g., "signed integer addition overflow in 'a + b'").
  • Added new compiler flags:
    • "-f[no-]sanitize-debug-trap-reasons" to control whether exception trap reasons are embedded in debug information when compiling with "-fsanitize-trap" mode.
    • "-fsanitize=alloc-token", "-falloc-token-max", "-fsanitize-alloc-token-fast-abi", and "-fsanitize-alloc-token-extended" to manage memory allocation tokens.
    • "-fmatrix-memory-layout" to control the memory layout of matrix types (e.g. column-major for column-major, row-major for row-major).
  • Functions now have a "malloc_span" attribute, similar to the malloc attribute but applicable to functions that return span-like structures containing a pointer and a field with the size or a pointer to the end of the block.
  • Added the "modular_format" attribute to dynamically select the required statically linked implementation of the printf function at link time.
  • Diagnostic and static analysis tools have been expanded, new checks have been added (several dozen diagnostic-related improvements).
  • Additional intrinsics for the SSE, AVX, and AVX512 extensions have been added to the X86 backend. Build modes have been added for Intel CPUs based on the Wildcat Lake (-march=wildcatlake) and Nova Lake (-march=novalake) microarchitectures.
  • The AArch64 backend now supports the Ampere Computing Ampere1C (ampere1c), Arm C1-Nano (c1-nano), Arm C1-Pro (c1-pro), Arm C1-Premium (c1-premium), and Arm C1-Ultra (c1-ultra) processors. Additional built-in functions have been added for the FCVTZ[US], FCVTN[US], FCVTM[US], FCVTP[US], and FCVTA[US] instructions. Function Multi-Versioning (FMV) support has been stabilized. Users can now override the priority of different function versions.
  • Added support for LoongArch32 (LA32R, LA32S) architecture.
  • Improved backends for ARM, AMDGPU, RISC-V, LoongArch64, MIPS, WebAssembly, and PowerPC architectures.

Source: opennet.ru

Buy reliable hosting for sites with DDoS protection, VPS VDS servers πŸ”₯ Buy reliable website hosting with DDoS protection, VPS VDS servers | ProHoster