[NFCI][WPD]Use unique string saver to store type id (#106932)
commit97b2903455fbe2de0c88cf07b92a09dc8cb7e699
authorMingming Liu <mingmingl@google.com>
Thu, 21 Nov 2024 07:44:18 +0000 (20 23:44 -0800)
committerGitHub <noreply@github.com>
Thu, 21 Nov 2024 07:44:18 +0000 (20 23:44 -0800)
tree78d133756a659cd52415862ca76b119b80140cf0
parenta6fefc82450e054336a52a5d2d915b780b8c3ef7
[NFCI][WPD]Use unique string saver to store type id (#106932)

Currently, both
[TypeIdMap](https://github.com/llvm/llvm-project/blob/67a1fdb014790a38a205d28e1748634de34471dd/llvm/include/llvm/IR/ModuleSummaryIndex.h#L1356)
and
[TypeIdCompatibleVtableMap](https://github.com/llvm/llvm-project/blob/67a1fdb014790a38a205d28e1748634de34471dd/llvm/include/llvm/IR/ModuleSummaryIndex.h#L1363)
keep type-id as `std::string` in the combined index for LTO indexing
analysis.

With this change, index uses a unique-string-saver to own the string
copies and two maps above can use string references to save some memory.

This shows a 3% memory reduction (from 8.2GiB to 7.9GiB) in an internal
binary with high indexing memory usage.
llvm/include/llvm/IR/ModuleSummaryIndex.h
llvm/include/llvm/IR/ModuleSummaryIndexYAML.h
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp