Release of the LLVM 10.0 compiler suite

After six months of development submitted project release LLVM 10.0 - GCC-compatible tools (compilers, optimizers and code generators) that compile programs into an intermediate bitcode of RISC-like virtual instructions (a low-level virtual machine with a multi-level optimization system). The generated pseudo-code can be converted by the JIT compiler into machine instructions right at the time of program execution.

New features in LLVM 10.0 include support for C++ Concepts, no longer runs Clang as a separate process, support for CFG (control flow guard) checks for Windows, and support for new CPU capabilities.

Improvements in Clang 10.0:

  • Added support forconcept", a C++ template extension that will be included in the next standard, codenamed C++2a (turned on by the -std=c++2a flag).
    Concepts allow you to define a set of template parameter requirements that, at compile time, limit the set of arguments that can be accepted as template parameters. The concepts can be used to avoid logical inconsistencies between the properties of the data types used within the template and the data type properties of the input parameters.

    template
    concept EqualityComparable = requires(T a, T b) {
    { a == b } -> std::boolean;
    { a != b } -> std::boolean;
    };

  • By default, the launch of a separate process (“clang -cc1”) in which compilation is performed is stopped. Compilation is now done in the main process, and the "-fno-integrated-cc1" option can be used to restore the old behavior.
  • New diagnostic modes:
    • "-Wc99-designator" and "-Wreorder-init-list" warn against using C99 initializers in C++ mode in cases where they are correct in C99 but not in C++20.
    • "-Wsizeof-array-div" - catches situations such as "int arr[10]; …sizeof(arr) / sizeof(short)…” (should be “sizeof(arr) / sizeof(int)”).
    • "-Wxor-used-as-po" - warns against the use of constructs such as the use of the "^" (xor) operator in operations that can be confused with exponentiation (2^16).
    • "-Wfinal-dtor-non-final-class" - warns about classes that are not marked with the "final" specifier, but have a destructor with the "final" attribute.
    • "-Wtautological-bitwise-compare" is a group of warnings for diagnosing tautological comparisons between a bitwise operation and a constant, and for identifying always-true comparisons in which the bitwise OR operation is applied to a non-negative number.
    • "-Wbitwise-conditional-parentheses" warns of problems when mixing the logical operators AND (&) and OR (|) with the conditional operator (?:).
    • “-Wmisleading-indentation” is an analogue of the check of the same name from GCC, which warns about indented expressions as if they are part of an if/else/for/while block, but in fact they are not included in this block.
    • When specifying “-Wextra”, the “-Wdeprecated-copy” check is enabled, warning about the use of constructors
      "move" and "copy" in classes with an explicit destructor definition.

    • The "-Wtautological-overlap-compare", "-Wsizeof-pointer-div", "-Wtautological-compare", "-Wrange-loop-analysis" checks have been expanded.
    • The "-Wbitwise-op-parentheses" and "-Wlogical-op-parentheses" checks are disabled by default.
  • In C and C++ code, pointer arithmetic operations are only allowed in arrays. The Undefined Behavior Sanitizer in "-fsanitize=pointer-overflow" mode now catches cases such as adding a non-zero offset to a null pointer or creating a null pointer when subtracting an integer from a non-null pointer.
  • The "-fsanitize=implicit-conversion" (Implicit Conversion Sanitizer) mode is adapted to identify problems with increment and decrement operations for types with a bit size smaller than that of the "int" type.
  • When selecting x86 target architectures "-march=skylake-avx512", "-march=icelake-client", "-march=icelake-server", "-march=cascadelake" and "-march=cooperlake" by default in vectorized The code has stopped using 512-bit zmm registers, except for their direct indication in the source code. The reason is that the CPU frequency decreases when performing 512-bit operations, which can negatively affect overall performance. To change the new behavior, the option "-mprefer-vector-width=512" is provided.
  • The behavior of the "-flax-vector-conversions" flag is similar to GCC: implicit vector bit conversions between integer and floating-point vectors are prohibited. To eliminate this limitation, it is proposed to use the flag
    "-flax-vector-conversions=all" which is the default.

  • Improved support for MIPS CPUs of the Octeon family. Added "octeon+" to the list of valid CPU types.
  • When assembling into WebAssembly intermediate code, the wasm-opt optimizer is automatically called, if available in the system.
  • For systems based on the RISC-V architecture, the use of registers storing floating point values ​​is allowed in conditional blocks of assembler inline inserts.
  • Added new compiler flags: "-fgnuc-version" to set the version value for "__GNUC__" and similar macros; "-fmacro-prefix-map=OLD=NEW" to replace the directory prefix OLD with NEW in macros such as "__FILE__"; "-fpatchable-function-entry=N[,M]" to generate a certain number of NOP instructions before and after the function entry point. For RISC-V
    added support for the "-ffixed-xX", "-mcmodel=medany" and "-mcmodel=medlow" flags.

  • Added support for the '__attribute__((target(“branch-protection=..."))) attribute, the effect of which is similar to the option -mbranch-protection.
  • On the Windows platform, when specifying the “-cfguard” flag, substitution of execution flow integrity checks (Control Flow Guard) for indirect function calls is implemented. To disable check substitution, you can use the “-cfguard-nochecks” flag or the “__declspec(guard(nocf))” modifier.
  • The behavior of the gnu_inline attribute is similar to GCC in cases where it is used without the "extern" keyword.
  • The capabilities associated with OpenCL and CUDA support have been expanded. Added support for new OpenMP 5.0 features.
  • A Standard option has been added to the clang-format utility, which allows you to determine the version of the C++ standard used when parsing and formatting code (Latest, Auto, c++03, c++11, c++14, c++17, c++20 ).
  • New checks have been added to the static analyzer: alpha.cplusplus.PlacementNew to determine whether there is sufficient storage space, fuchsia.HandleChecker to detect leaks related to Fuchsia handlers, security.insecureAPI.decodeValueOfObjCType to detect potential buffer overflows when using [NSCoder decodeValueOfObjCType:at:] .
  • The Undefined Behavior Sanitizer (UBSan) has expanded its pointer overflow checks to catch the application of non-zero offsets to NULL pointers or the resulting addition of a NULL pointer offset.
  • In linter clang-tidy added a large portion of new checks.

All innovations LLVM 10.0:

  • In framework Attributor New interprocedural optimizations and analyzers have been added. The state of 19 different attributes is predicted, including 12 attributes 12 LLVM IR and 7 abstract attributes such as liveness.
  • Added new matrix mathematical functions built into the compiler (intrinsics), which are replaced by efficient vector instructions during compilation.
  • Numerous improvements have been made to backends for X86, AArch64, ARM, SystemZ, MIPS, AMDGPU and PowerPC architectures. Added CPU support
    Cortex-A65, Cortex-A65AE, Neoverse E1 and Neoverse N1. For ARMv8.1-M, ​​the code generation process has been optimized (for example, support for loops with minimal overhead has appeared) and support for autovectorization has been added using the MVE extension. Improved CPU MIPS Octeon support. For PowerPC, vectorization of mathematical subroutines using the MASSV (Mathematical Acceleration SubSystem) library is enabled, code generation is improved, and memory access from loops is optimized. For x86, the handling of vector types v2i32, v4i16, v2i16, v8i8, v4i8 and v2i8 has been changed.

  • Improved code generator for WebAssembly. Added support for TLS (Thread-Local Storage) and atomic.fence instructions. SIMD support has been significantly expanded. WebAssembly object files now have the ability to use multi-valued function signatures.
  • The analyzer is used when processing loops MemorySSA, which allows you to define dependencies between different memory operations. MemorySSA can reduce compilation and execution time or can be used instead of AliasSetTracker without loss of performance.
  • The LLDB debugger has significantly improved support for the DWARF v5 format. Improved support for building with MinGW
    and added initial ability to debug Windows executables for ARM and ARM64 architectures. Added descriptions of the options offered when autocompleting input by pressing tab.

  • Expanded LLD linker capabilities. Improved support for the ELF format, including ensuring full compatibility of glob templates with the GNU linker, adding support for compressed debug sections ".zdebug", adding the PT_GNU_PROPERTY property to define the .note.gnu.property section (can be used in future Linux kernels),
    The “-z noseparate-code”, “-z separate-code” and “-z separate-loadable-segments” modes have been implemented. Improved support for MinGW and WebAssembly.

Source: opennet.ru

Add a comment