[all-commits] [llvm/llvm-project] 29bb52: [LTO] Introduce a helper lambda in gatherImportedS...

Kazu Hirata via All-commits all-commits at lists.llvm.org
Tue Aug 27 12:43:28 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 29bb523b7c3502b47737ced2a8b20678809ec9de
      https://github.com/llvm/llvm-project/commit/29bb523b7c3502b47737ced2a8b20678809ec9de
  Author: Kazu Hirata <kazu at google.com>
  Date:   2024-08-27 (Tue, 27 Aug 2024)

  Changed paths:
    M llvm/include/llvm/IR/ModuleSummaryIndex.h
    M llvm/lib/Transforms/IPO/FunctionImport.cpp

  Log Message:
  -----------
  [LTO] Introduce a helper lambda in gatherImportedSummariesForModule (NFC) (#106251)

This patch forward ports the heterogeneous std::map::operator[]() from
C++26 so that we can look up the map without allocating an instance of
std::string when the key-value pair exists in the map.

The background is as follows.  I'm planning to reduce the memory
footprint of ThinLTO indexing by changing ImportMapTy, the data
structure used for an import list.  The new list will be a hash set of
tuples (SourceModule, GUID, ImportType) represented in a space
efficient manner.  That means that as we iterate over the hash set, we
encounter SourceModule as many times as GUID.  We don't want to create
a temporary instance of std::string every time we look up
ModuleToSummariesForIndex like:

auto &SummariesForIndex =
ModuleToSummariesForIndex[std::string(ILI.first)];

This patch removes the need to create the temporaries by enabling the
hetegeneous lookup with std::set<K, V, std::less<>> and forward
porting std::map::operator[]() from C++26.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list