diff options
author | Mingming Liu <mingmingl@google.com> | 2024-11-20 23:44:18 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-20 23:44:18 -0800 |
commit | 97b2903455fbe2de0c88cf07b92a09dc8cb7e699 (patch) | |
tree | 78d133756a659cd52415862ca76b119b80140cf0 /llvm/lib/Bitcode/Writer/BitcodeWriter.cpp | |
parent | a6fefc82450e054336a52a5d2d915b780b8c3ef7 (diff) | |
download | llvm-97b2903455fbe2de0c88cf07b92a09dc8cb7e699.zip llvm-97b2903455fbe2de0c88cf07b92a09dc8cb7e699.tar.gz llvm-97b2903455fbe2de0c88cf07b92a09dc8cb7e699.tar.bz2 |
[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.
Diffstat (limited to 'llvm/lib/Bitcode/Writer/BitcodeWriter.cpp')
-rw-r--r-- | llvm/lib/Bitcode/Writer/BitcodeWriter.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp index 80e12be..59e070a 100644 --- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -4165,7 +4165,7 @@ static void writeWholeProgramDevirtResolution( static void writeTypeIdSummaryRecord(SmallVector<uint64_t, 64> &NameVals, StringTableBuilder &StrtabBuilder, - const std::string &Id, + StringRef Id, const TypeIdSummary &Summary) { NameVals.push_back(StrtabBuilder.add(Id)); NameVals.push_back(Id.size()); @@ -4184,7 +4184,7 @@ static void writeTypeIdSummaryRecord(SmallVector<uint64_t, 64> &NameVals, static void writeTypeIdCompatibleVtableSummaryRecord( SmallVector<uint64_t, 64> &NameVals, StringTableBuilder &StrtabBuilder, - const std::string &Id, const TypeIdCompatibleVtableInfo &Summary, + StringRef Id, const TypeIdCompatibleVtableInfo &Summary, ValueEnumerator &VE) { NameVals.push_back(StrtabBuilder.add(Id)); NameVals.push_back(Id.size()); |