6 Commits

Author SHA1 Message Date
SharonXSharon
6827a00d4d
[lld][InstrProf] Do not use cstring offset hashes in function order for compression (#113606) 2024-10-28 09:47:21 -07:00
Ellis Hoag
ce91e2153f
[lld][InstrProf] Sort startup functions for compression (#107348) 2024-09-06 09:22:03 -07:00
Ellis Hoag
3380dae2f0
[lld][InstrProf] Refactor BPSectionOrderer.cpp (#107347)
Refactor some code in `BPSectionOrderer.cpp` in preparation for
https://github.com/llvm/llvm-project/pull/107348.

* Rename `constructNodesForCompression()` -> `getUnsForCompression()`
and return a `SmallVector` directly rather than populating a vector
alias
* Pass `duplicateSectionIdxs` as a pointer to make it possible to skip
finding (nearly) duplicate sections
* Combine `duplicate{Function,Data}SectionIdxs` into one variable
* Compute all `BPFunctionNode` vectors at the end (like
`nodesForStartup`)

There should be no functional change.
2024-09-05 14:55:05 -07:00
Ellis Hoag
f95bd62cf9
[lld][InstrProf] Add "Separate" irpgo-profile-sort option (#101084)
Add the "Separate" option `--irpgo-profile-sort <profile` instead of
just the "Joined" option `--irpgo-profile-sort=<profile>`. This is
useful if the path has a `,` for some reason which would break when
trying to use `-Wl,--irpgo-profile-sort=<profile-with-comma>`.

While I'm here, use `static_cast<>` instead of the C style cast
introduced in https://github.com/llvm/llvm-project/pull/100627
2024-08-01 11:20:01 -07:00
Scott Todd
4f8050806e
[lld] Add explicit conversion for enum to Twine. (#100627)
This fixes `error: ambiguous conversion for functional-style cast from
'lld::macho::InputSection::Kind' to 'llvm::Twine'`, observed when
building with clang-9 and reported here:
https://github.com/llvm/llvm-project/pull/96268#discussion_r1691909931.
2024-07-25 11:37:31 -07:00
Ellis Hoag
e3b30bc553
[lld][InstrProf] Profile guided function order (#96268)
Add the lld flags `--irpgo-profile-sort=<profile>` and
`--compression-sort={function,data,both}` to order functions to improve
startup time, and functions or data to improve compressed size,
respectively.

We use Balanced Partitioning to determine the best section order using
traces from IRPGO profiles (see
https://discourse.llvm.org/t/rfc-temporal-profiling-extension-for-irpgo/68068
for details) to improve startup time and using hashes of section
contents to improve compressed size.

In our recent LLVM talk (https://www.youtube.com/watch?v=yd4pbSTjwuA),
we showed that this can reduce page faults during startup by 40% on a
large iOS app and we can reduce compressed size by 0.8-3%.

More details can be found in https://dl.acm.org/doi/10.1145/3660635

---------

Co-authored-by: Vincent Lee <thevinster@users.noreply.github.com>
2024-07-23 08:34:40 -07:00