[lld-macho] Include ICF safe thunks in balanced partitioning (#212096)

Mach-O balanced partitioning currently discovers candidate sections by
walking the input-file section graph. In `--icf=safe_thunks` mode,
address-significant functions can instead be emitted as linker-created
thunk sections after that graph has been built. A temporal-profile name
then resolves to the dead folded input while the callable section
present in the final binary is never eligible for BP ordering.

Factor candidate collection into a helper, then inspect the final
`inputSections` set for sections containing a `Defined` symbol marked
`ICFFoldKind::Thunk`. This makes emitted ICF safe thunks visible while
keeping unrelated synthetic metadata outside BP.

The new arm64 regression folds a profiled address-significant function
into a 4-byte safe thunk and verifies both the BP startup count and
final symbol order. Without the change, BP orders zero startup sections
for that profile; with the change it orders the emitted thunk first.

GitOrigin-RevId: 25d130fc7efffd4d6b87ad9ab5193ce10cf37edb
2 files changed
tree: 0bb74a48389bb9a120e18203841c7a22947ddad0
  1. cmake/
  2. COFF/
  3. Common/
  4. docs/
  5. ELF/
  6. include/
  7. MachO/
  8. MinGW/
  9. test/
  10. tools/
  11. unittests/
  12. utils/
  13. wasm/
  14. .clang-format
  15. .clang-tidy
  16. .gitignore
  17. CMakeLists.txt
  18. LICENSE.TXT
  19. Maintainers.md
  20. README.md
README.md

LLVM Linker (lld)

This directory and its subdirectories contain source code for the LLVM Linker, a modular cross platform linker which is built as part of the LLVM compiler infrastructure project.

lld is open source software. You may freely distribute it under the terms of the license agreement found in LICENSE.txt.

Benchmarking

In order to make sure various developers can evaluate patches over the same tests, we create a collection of self contained programs.

It is hosted at https://s3-us-west-2.amazonaws.com/linker-tests/lld-speed-test.tar.xz

The current sha256 is 10eec685463d5a8bbf08d77f4ca96282161d396c65bd97dc99dbde644a31610f.