[all-commits] [llvm/llvm-project] 23c8d3: [BOLT] Calculate input to output address map using...

Job Noorman via All-commits all-commits at lists.llvm.org
Mon Aug 21 01:37:01 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 23c8d382583167812cfe59aed0d004bdbdcd9fba
      https://github.com/llvm/llvm-project/commit/23c8d382583167812cfe59aed0d004bdbdcd9fba
  Author: Job Noorman <jnoorman at igalia.com>
  Date:   2023-08-21 (Mon, 21 Aug 2023)

  Changed paths:
    A bolt/include/bolt/Core/AddressMap.h
    M bolt/include/bolt/Core/BinaryBasicBlock.h
    M bolt/include/bolt/Core/BinaryContext.h
    M bolt/include/bolt/Core/BinaryFunction.h
    M bolt/include/bolt/Core/BinarySection.h
    A bolt/lib/Core/AddressMap.cpp
    M bolt/lib/Core/BinaryBasicBlock.cpp
    M bolt/lib/Core/BinaryEmitter.cpp
    M bolt/lib/Core/BinaryFunction.cpp
    M bolt/lib/Core/CMakeLists.txt
    M bolt/lib/Profile/BoltAddressTranslation.cpp
    M bolt/lib/Rewrite/PseudoProbeRewriter.cpp
    M bolt/lib/Rewrite/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Calculate input to output address map using BOLTLinker

BOLT uses MCAsmLayout to calculate the output values of basic blocks.
This means output values are calculated based on a pre-linking state and
any changes to symbol values during linking will cause incorrect values
to be used.

This issue was first addressed in D154604 by adding all basic block
symbols to the symbol table for the linker to resolve them. However, the
runtime overhead of handling this huge symbol table turned out to be
prohibitively large.

This patch solves the issue in a different way. First, a temporary
section containing [input address, output symbol] pairs is emitted to the
intermediary object file. The linker will resolve all these references
so we end up with a section of [input address, output address] pairs.
This section is then parsed and used to:
- Replace BinaryBasicBlock::OffsetTranslationTable
- Replace BinaryFunction::InputOffsetToAddressMap
- Update BinaryBasicBlock::OutputAddressRange

Note that the reason this is more performant than the previous attempt
is that these symbol references do not cause entries to be added to the
symbol table. Instead, section-relative references are used for the
relocations.

Reviewed By: maksfb

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




More information about the All-commits mailing list