48 Star 41 Fork 220

OpenHarmony/third_party_llvm-project

[R&D] Introduction to llvm15 upgrade

已完成
任务 成员
创建于  
2023-02-20 15:38

【任务描述】
We are doing llvm 15 upgrade, It will be helpful if we can know what is new in llvm 15 compared to our currently toolchain(llvm 12).

It doesn't need to be too detailed, just big upgrades like new features, optimations, etc.
【解决方案】

【任务来源】

评论 (2)

guzhihao4 创建了任务 2年前
Pavel Kosov 任务状态待办的 修改为进行中 2年前
Pavel Kosov 负责人设置为Khomutov Nikita 2年前
Pavel Kosov 修改了描述 2年前
Pavel Kosov 修改了标题 2年前
展开全部操作日志

Interesting changes are new features, optimizations, tooling enhancements, deprecations and breaking changes. Deprecations should also be taken in care: deprecation can be trasformed into a breaking change in newer version, so it better to be prepared for a seamless migration.

Original diffs can be found in release notes of LLVM / Clang project:
LLVM13, LLVM14, LLVM15, Clang13, Clang14, Clang15.

I've summarized this in a structured way. You can skip uninterested sections while reading to find what is more relevant.

However, not all the changes can be found in release notes: some weak guarantees may be broken for minor reasons that are not highlighted at all (like C++ demangling changes made for debugging simplification).

Most noticiable changes are:

  • breaking change in LLVM IR: opaque pointers
  • backend improvements in ARM, AArch64, RISC-V
  • memory tags in LLDB (related to AArch64 MTE)
  • tooling enchancements

LLVM

! Note the major breaking changes:

  • LLVM IR, opaque pointer types. Typed pointers are deprecated now. It is planned to drop support of typed pointers in LLVM 16. It means all external dependencies on IR (like tools, build caches, ML models) have to be migrated here.
  • This also involves breaking changes in C API: a series of new functions, renames are made to establish non-drop-in migration process. It has a relatively large list of changes: see 13, 14, 15 for details. Looks like frontend / tooling developers should take care of this.

LLVM IR

  • typed pointers are deprecated, opaque ones will be used: the process is planned to be finalized in LLVM16 (requires huge refactoring).
  • legacy pass manager is deprecated and become unmaitained
  • max allowed integer type was reduced from 2^24-1 bits to 2^23 bits.
  • max allowed alignment was increased from 2^29 to 2^32.
  • stabilized vector intrinsic:
    • llvm.experimental.vector.extract -> llvm.vector.extract, doc
    • llvm.experimental.vector.insert -> llvm.vector.insert, doc
  • constant expression variants of the following instructions have been removed: extractvalue, insertvalue, udiv, sdiv, urem, srem, fadd, fsub, fmul, fdiv
  • added the support for fmax and fmin in atomicrmw instruction. The comparison is expected to match the behavior of llvm.maxnum.* and llvm.minnum.* respectively.
  • callbr instructions no longer use blockaddress arguments for labels. Instead, label constraints starting with ! refer directly to entries in the callbr indirect destination list.

Backends

Main efforts were made for ARM, AArch64, RISC-V and PowerPC backends.
More architectures and CPUs are supported.

AArch64 has auto-vectorization now.

Various extensions are added and stabilized in RISC-V. Also various optimizations implemented and improved for RISC-V.

AArch64

Arch:

  • Added support for the Armv9-A, Armv9.1-A and Armv9.2-A architectures.
  • Introduced assembly support for Armv9-A’s Realm Management Extension (RME) and Scalable Matrix Extension (SME).

Features:

  • The compiler now recognises the tune-cpu function attribute to support the use of the -mtune frontend flag. This allows certain scheduling features and optimisations to be enabled independently of the architecture. If the tune-cpu attribute is absent it tunes according to the target-cpu.
  • Auto-vectorization now targets SVE by default when available.

Fixes:

  • Produce proper cross-section relative relocations on COFF
  • Fixed relocations against temporary symbols (e.g. in jump tables and constant pools) in large COFF object files.
  • Fixed the calling convention on Windows for variadic functions involving floats in the fixed arguments

ARM

Arch:

  • Added support for the Armv9-A, Armv9.1-A and Armv9.2-A architectures.
  • Added support for the Armv8.1-M PACBTI-M extension.
  • Removed the deprecation of ARMv8-A T32 Complex IT blocks. No deprecation warnings will be generated and -mrestrict-it is now always off by default. Previously it was on by default for Armv8 and off for all other architecture versions.
  • Added a pass to workaround Cortex-A57 Erratum 1742098 and Cortex-A72 Erratum 1655431. This is enabled by default when targeting either CPU.
  • Added support for the Cortex-M85 CPU.

Features:

  • Implemented generation of Windows SEH unwind information.
  • Switched the MinGW target to use SEH instead of DWARF for unwind information.
  • Added support for a new -mframe-chain=(none|aapcs|aapcs+leaf) command-line option, which controls the generation of AAPCS-compliant Frame Records.

Fixes:

  • Produce proper cross-section relative relocations on COFF

RISC-V

Optimizations:

  • Codegen improvements for RV64 around the selection of addw/subw/mulw/slliw instructions and removal of redundant sext.w instructions (using the new RISCVSExtWRemoval pass).
  • Various improvements to immediate materialisation, including when bit-manipulation extensions are enabled. Additionally, the constant pool is now used for large integers.
  • A RISCVRedundantCopyElimination pass was added to remove unnecessary zero copies.
  • A RISC-V specific CodeGenPrepare pass was added.
  • The machine outliner was enabled by default for RISC-V at -Oz. Additionally, the newly introduced RISCVMakeCompressible pass will make modify instructions prior to emission at -Oz in order to increase opportunities for the compression with the RISC-V C extension.
  • Various improvements were made to RISC-V specific optimisation passes such as RISCVSExtWRemoval and RISCVMergeBaseOffset.

Extensions:

  • The various RISC-V vector extensions were updated to version 1.0 and are no longer experimental.
  • The Zba, Zbb, Zbc, and Zbs bit-manipulation extensions were updated to version 1.0 and are no longer experimental.
  • The Zfh and Zfhmin extensions for half-precision floating point were updated to version 1.0 and are no longer experimental.
  • The experimental Zbproposedc extension was removed, as was the B extension (including all bit-manipulation sub-extensions). Individual Zb* extensions should be used instead.
  • Support for the experimental Zvfh extension was added, enabling half-precision floating point in vectors.
  • Support for the Zihintpause (Pause Hint) extension.
  • Assembler and disassembler support for the Zfinx and Zdinx (float / double in integer register) extensions.
  • Assembler and disassembler support for the Zicbom, Zicboz, and Zicbop cache management operation extensions.
  • Support for the Zmmul extension (a subextension of the M extension, adding multiplication instructions only).
  • Assembler and disassembler support for the hypervisor extension and for the Sinval supervisor memory-management extension.
  • Added MC layer support for the ratified scalar cryptography extensions.
  • Added support for the .insn directive.
  • Added support for constrained FP intrinsics for scalar types.
  • Added support for CSRs introduced in the Sscofpmf, Smstateen, and Sstc extensions.

Etc:

  • Various bug fixes and improvements to code generation for the RISC-V vector extensions.
  • llc now computes the target ABI based on the target architecture using the same logic as Clang if not explicit ABI is given.
  • generic is now recognized as a valid CPU name and is mapped to generic-rv32 or generic-rv64 depending on the target triple.

X86

  • Support for AVX512-FP16 instructions has been added.
  • Removed incomplete support for Intel MPX

Other

  • AMDGPU: 8 and 16-bit atomic loads and stores are now supported
  • PowerPC: 14, 15

LLVM Tooling

See change list here 12.0.0, 13.0.0, 14.0.0, 15.0.0 for details.

CLI flags changes and deprecations potentially can affect your automation scripts, take care of it. Some tools are not guaranteed to have a stable CLI API neither for input flags, neither for output format. Several tools have changed its output format to be closer to GNU pairs (e.g. llvm-objdump <-> objdump).

Performance Analyer:

  • llvm-mca: support for in-order CPUs (e.g. ARM Cortex-A55)
  • Note: llvm-mca requires proper scheduling model for your target to get relevant results. [MCA docs].

Artifact Tools

New features, changes in behavior (tool names are clickable)

  • llvm-ar:

    • support for --thin archives
    • supports reading big archives for XCOFF
    • new flag -X to specify the type of object file should be processed
  • llvm-nm:

    • now demangles Rust symbols
    • supports XCOFF object files
    • new flag -X to specify the type object file should be processed
    • new option --export-symbols to dump a list of unique symbols used for export
  • llvm-rc (port of Windows's rc.exe):

    • support for invoking Clang for input preprocessing
    • support GNU windres compatible frontends
  • llvm-objcopy:

    • support --update-section for ELF and Mach-O
    • support --subsystem for PE/COFF
    • mips64le relocations for ELF
    • now supports 32 bit XCOFF
    • improved assembly printing for XCOFF
    • --rename-section now renames relocation sections together with their targets (GNU like)
    • removed support for the legacy zlib-gnu format
    • now allows --set-section-flags src=... --rename-section src=tst
    • --add-section=.foo1=... --rename-section=.foo1=.foo2 now adds .foo1 instead of .foo2.
  • llvm-objdump:

    • --symbolize-operands now supports PowerPC
    • -p now dumps PE header (GNU like)
    • -R now supports ELF position-dependent executables
    • -T now prints symbol versions (GNU like)
  • llvm-readobj:

    • improvements for Windows unwind data; several new dump styles --needed-libs, --relocs, --syms for XCOFF
    • support for --elf-output-style=JSON and --pretty-print
  • llvm-symbolizer: now has --filter-markup to filter Symbolizer Markup into human-readable form.

  • llc: now parses code-model attribute from input file

Tool CLI API changes:

  • llvm-readobj --sections -> llvm-readobj --syms
  • llvm-readobj --syms -> llmv-readobj --section-details
  • llvm-nm flags -M, -U, -W are deprecated
  • More GNU-like output for various tools

LLDB

Most noticable changes are improved AArch64 and memory tagging (MTE) support.
Read the post https://www.linaro.org/blog/debugging-memory-tagging-with-lldb-13/ for details and usage examples.

AArch64:

  • full featured support for AArch64 SVE register access.
  • support AArch64 Pointer Authentication, allowing stack unwind with signed return address.
  • support debugging programs on AArch64 Linux that use memory tagging (MTE).

Memory tags related changes:

  • Added memory tag read and memory tag write commands.
  • The memory region command will note when a region has memory tagging enabled.
  • Synchronous and asynchronous tag faults are recognised.
  • Synchronous tag faults have memory tag annotations in addition to the usual fault address.
  • LLDB now supports reading memory tags from AArch64 Linux core files.
  • The following commands now ignore non-address bits (e.g. AArch64 pointer signatures) in address arguments. In addition, non-address bits will not be shown in the output of the commands.
    • memory find
    • memory read
    • memory region (see below)
    • memory tag read
    • memory tag write
  • The memory region command and GetMemoryRegionInfo API method now ignore non-address bits in the address parameter. This also means that on systems with non-address bits the last (usually unmapped) memory region will not extend to 0xF…F. Instead it will end at the end of the mappable range that the virtual address size allows.
  • The memory read command has a new option --show-tags. Use this option to show memory tags beside the contents of tagged memory ranges.
  • The memory region command now has a –all option to list all memory regions (including unmapped ranges). This is the equivalent of using address 0 then repeating the command until all regions have been listed.
  • Added –show-tags option to the memory find command. This is off by default. When enabled, if the target value is found in tagged memory, the tags for that memory will be shown inline with the memory contents.
  • Various memory related parts of LLDB have been updated to handle non-address bits (such as AArch64 pointer signatures):
    • memory read, memory write and memory find can now be used with addresses with non-address bits.
    • All the read and write memory methods on SBProccess and SBTarget can be used with addreses with non-address bits.
    • When printing a pointer expression, LLDB can now dereference the result even if it has non-address bits.
    • The memory cache now ignores non-address bits when looking up memory locations. This prevents us reading locations multiple times, or not writing out new values if the addresses have different non-address bits.

Etc:

  • A change in Clang’s type printing has changed the way LLDB names array types (from int [N] to int[N]) - LLDB pretty printer type name matching code may need to be updated to handle this.
  • Fixed continuing from breakpoints and singlestepping on Windows on ARM/ARM64.
  • LLDB now supports the gnu debuglink section for reading debug information from a separate file on Windows
  • LLDB now allows selecting the C++ ABI to use on Windows (between Itanium, used for MingW, and MSVC) via the plugin.object-file.pe-coff.abi setting. In Windows builds of LLDB, this defaults to the style used for LLVM’s default target.

Clang

Major features

  • Guaranteed tail calls are now supported with statement attributes [[clang::musttail]] in C++ and __attribute__((musttail)) in C. The attribute is applied to a return statement (not a function declaration), and an error is emitted if a tail call cannot be guaranteed, for example if the function signatures of caller and callee are not compatible. Guaranteed tail calls enable a class of algorithms that would otherwise use an arbitrary amount of stack space.

  • Added SPIR-V triple and binary generation using external llvm-spirv tool.

  • Completed support of OpenCL C 3.0 and C++ for OpenCL 2021 at experimental state.

  • Clang now supports the -fzero-call-used-regs feature for x86. The purpose of this feature is to limit Return-Oriented Programming (ROP) exploits and information leakage. It works by zeroing out a selected class of registers before function return — e.g., all GPRs that are used within the function. There is an analogous zero_call_used_regs attribute to allow for finer control of this feature.

  • Clang now supports randomizing structure layout in C. This feature is a compile-time hardening technique, making it more difficult for an attacker to retrieve data from structures. Specify randomization with the randomize_layout attribute. The corresponding no_randomize_layout attribute can be used to turn the feature off.
    A seed value is required to enable randomization, and is deterministic based on a seed value. Use the -frandomize-layout-seed= or -frandomize-layout-seed-file= flags.

  • Clang now supports the -fstrict-flex-arrays=<arg> option to control which array bounds lead to flexible array members. The option yields more accurate __builtin_object_size and __builtin_dynamic_object_size results in most cases but may be overly conservative for some legacy code.

  • Experimental support for HLSL has been added. The implementation is incomplete and highly experimental.

C++ 2b status support

See a table https://clang.llvm.org/cxx_status.html to track what desired features are implemented in Clang15.

Etc

  • Many changes were made for implementing OpenCL Kernel support.
  • New AST matchers are available 14, 15 for building analyzers atop of clang.
  • SPIR-V support allows you to build Vulkan shaders with clang.

Other

  • BOLT project is added to the LLVM monorepo. BOLT is a post-link optimizer developed to speed up large applications. Readme
Pavel Kosov 任务状态进行中 修改为已完成 2年前

登录 后才可以发表评论

状态
负责人
项目
里程碑
Pull Requests
关联的 Pull Requests 被合并后可能会关闭此 issue
分支
开始日期   -   截止日期
-
置顶选项
优先级
预计工期 (小时)
参与者(2)
guzhihao4-guzhihao4 11642396 urandon 1744479849
C++
1
https://gitee.com/openharmony/third_party_llvm-project.git
git@gitee.com:openharmony/third_party_llvm-project.git
openharmony
third_party_llvm-project
third_party_llvm-project

搜索帮助