[lld] [llvm] [NFCI][LTO][lld] Optimize away symbol copies within LTO global resolution in ELF (PR #106193)

Mingming Liu via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 5 09:37:25 PDT 2024


minglotus-6 wrote:

> When a bitcode file is parsed lazily [1], undefined symbols in a module won't [get saved](https://github.com/llvm/llvm-project/blob/2c7e1b8893061fdf487f2d9945d2d1eecd59a604/lld/ELF/InputFiles.cpp#L1799-L1802). In a LTO unit, a symbol is saved as long as one module defines it.
> 
> I'll add some logs in LTO class to see how undefined symbols are resolved. If LTO cannot rely on string savers' copies for undefined symbols, it needs to keep copies of undefined symbols itself (still a subset).

In the updated PR, `BitcodeFile::parseLazy` keeps copies of undefined symbols in a module (https://github.com/llvm/llvm-project/pull/106193/commits/dbfb00c119888ccab09fbdb6d201301049174200#diff-1a6e8fdd6339ca831ba81ed9fb4f94c42419f91d67c9e16322b71a3e011b42d2R1804-R1807). Now this PR should land after https://github.com/llvm/llvm-project/pull/106670.

Experiment data are collected on two benchmarks, stacking this PR on top of https://github.com/llvm/llvm-project/pull/106670

* LTO peak memory, measured before [indexing returns](https://github.com/llvm/llvm-project/blob/77f04882251b1e44239d6d7545cd62301e903a4a/lld/ELF/LTO.cpp#L356-L357)
  |                                                                                                |search1|search2|
  |------------------------------------------------------------------------------------------------|-------|-------|
  |1. HEAD                                                                                         |3.4GiB |9.89GiB|
  |2. Use unique string saver for symbol parsing (https://github.com/llvm/llvm-project/pull/106670)|3.3GiB |8.48GiB|
  |Stack this PR on top of 2                                                                       |3.1GiB |8.37GiB|



https://github.com/llvm/llvm-project/pull/106193


More information about the llvm-commits mailing list