[all-commits] [llvm/llvm-project] 0aa6df: [Propeller] Encode address offsets of basic blocks...

Rahman Lavaee via All-commits all-commits at lists.llvm.org
Tue Jun 28 07:46:27 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 0aa6df65756d3ec7769e55424a41c7074849fe12
      https://github.com/llvm/llvm-project/commit/0aa6df65756d3ec7769e55424a41c7074849fe12
  Author: Rahman Lavaee <rahmanl at google.com>
  Date:   2022-06-28 (Tue, 28 Jun 2022)

  Changed paths:
    M llvm/docs/Extensions.rst
    M llvm/include/llvm/BinaryFormat/ELF.h
    M llvm/include/llvm/MC/MCContext.h
    M llvm/include/llvm/ObjectYAML/ELFYAML.h
    M llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
    M llvm/lib/CodeGen/BasicBlockSections.cpp
    M llvm/lib/MC/MCSectionELF.cpp
    M llvm/lib/Object/ELF.cpp
    M llvm/lib/Object/ELFObjectFile.cpp
    M llvm/lib/ObjectYAML/ELFEmitter.cpp
    M llvm/lib/ObjectYAML/ELFYAML.cpp
    M llvm/test/CodeGen/X86/basic-block-sections-labels-empty-function.ll
    M llvm/test/CodeGen/X86/basic-block-sections-labels-functions-sections.ll
    M llvm/test/CodeGen/X86/basic-block-sections-labels.ll
    M llvm/test/tools/llvm-objdump/X86/elf-bbaddrmap-disassemble-symbolize-operands.yaml
    M llvm/test/tools/llvm-readobj/ELF/bb-addr-map.test
    M llvm/test/tools/obj2yaml/ELF/bb-addr-map.yaml
    M llvm/test/tools/yaml2obj/ELF/bb-addr-map.yaml
    M llvm/tools/llvm-readobj/ELFDumper.cpp
    M llvm/tools/obj2yaml/elf2yaml.cpp
    M llvm/unittests/Object/ELFObjectFileTest.cpp

  Log Message:
  -----------
  [Propeller] Encode address offsets of basic blocks relative to the end of the previous basic blocks.

This is a resurrection of D106421 with the change that it keeps backward-compatibility. This means decoding the previous version of `LLVM_BB_ADDR_MAP` will work. This is required as the profile mapping tool is not released with LLVM (AutoFDO). As suggested by @jhenderson we rename the original  section type value to `SHT_LLVM_BB_ADDR_MAP_V0` and assign a new value to the `SHT_LLVM_BB_ADDR_MAP` section type. The new encoding adds a version byte to each function entry to specify the encoding version for that function.  This patch also adds a feature byte to be used with more flexibility in the future. An use-case example for the feature field is encoding multi-section functions more concisely using a different format.

Conceptually, the new encoding emits basic block offsets and sizes as label differences between each two consecutive basic block begin and end label. When decoding, offsets must be aggregated along with basic block sizes to calculate the final offsets of basic blocks relative to the function address.

This encoding uses smaller values compared to the existing one (offsets relative to function symbol).
Smaller values tend to occupy fewer bytes in ULEB128 encoding. As a result, we get about 17% total reduction in the size of the bb-address-map section (from about 11MB to 9MB for the clang PGO binary).
The extra two bytes (version and feature fields) incur a small 3% size overhead to the `LLVM_BB_ADDR_MAP` section size.

Reviewed By: jhenderson

Differential Revision: https://reviews.llvm.org/D121346




More information about the All-commits mailing list