diff options
| author | Jan Voung <jvoung@gmail.com> | 2024-06-20 21:04:14 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-20 21:04:14 -0400 |
| commit | e1e5ed5893c50918dc9b6b56acfe6242f03354dc (patch) | |
| tree | 48351fc78039b83c65f08fdbb786f78fb543509b /llvm/lib/Bitcode/Reader/BitcodeReader.cpp | |
| parent | 2fe8498654fe5db68c585fc9fa4cd84d634e53df (diff) | |
Update ModuleSummaryIndexBitcodeReader::makeCallList reserve amount (#95461)
Tighten the reserve() to `Record.size() / 2` instead of `Record.size()`
in the HasProfile/HasRelBF cases. For the uncommon old profile format
cases we leave it as is, but those should be rare and not worth
optimizing.
This reduces peak memory during ThinLTO indexing by ~3% in one example.
Alternatively, we could make the branching for reserve more complex and
try to cover every case.
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp')
| -rw-r--r-- | llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index 06d99366a8c3..6bcd0c17400d 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -7333,7 +7333,13 @@ ModuleSummaryIndexBitcodeReader::makeCallList(ArrayRef<uint64_t> Record, bool IsOldProfileFormat, bool HasProfile, bool HasRelBF) { std::vector<FunctionSummary::EdgeTy> Ret; - Ret.reserve(Record.size()); + // In the case of new profile formats, there are two Record entries per + // Edge. Otherwise, conservatively reserve up to Record.size. + if (!IsOldProfileFormat && (HasProfile || HasRelBF)) + Ret.reserve(Record.size() / 2); + else + Ret.reserve(Record.size()); + for (unsigned I = 0, E = Record.size(); I != E; ++I) { CalleeInfo::HotnessType Hotness = CalleeInfo::HotnessType::Unknown; bool HasTailCall = false; |
