[lld] [LLD][ELF] add bp-* options in ELF (PR #120514)
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sun Jan 5 21:19:42 PST 2025
MaskRay wrote:
@ellishg Hopefully I understand the features correctly...
### `--bp-compression-sort=` and `--bp-startup-sort=`
Both options instruct the linker to optimize section layout with the following goals:
* `--bp-compression-sort=[data|function|both]`: Improve Lempel-Ziv compression by grouping similar sections together, resulting in a smaller compressed app size.
* `--bp-startup-sort=function --irpgo-profile=<file>`: Utilize a temporal profile file to reduce page faults during program startup.
The linker determines the section order by considering three groups:
* Function sections ordered according to the temporal profile (`--irpgo-profile=`), prioritizing early-accessed and frequently accessed functions.
* Function sections. Sections containing similar functions are placed together, maximizing compression opportunities.
* Data sections. Similar data sections are placed together.
Within each group, the sections are ordered using the Balanced Partitioning algorithm.
The linker constructs a bipartite graph with two sets of vertices: sections and utility vertices.
* For profile-guided function sections:
+ The number of utility vertices is determined by the symbol order within the profile file.
+ If `--bp-compression-sort-startup-functions` is specified, extra utility vertices are allocated to prioritize nearby function similarity.
* For sections ordered for compression: Utility vertices are determined by analyzing k-mers of the section content and relocations.
The call graph profile is disables during this optimization.
When `--symbol-ordering-file=` is specified, sections described in that file are placed earlier.
https://github.com/llvm/llvm-project/pull/120514
More information about the llvm-commits
mailing list