Skip to content

Commit 7542031

Browse files
jvoungAlexisPerry
authored andcommitted
Update ModuleSummaryIndexBitcodeReader::makeCallList reserve amount (llvm#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.
1 parent 3b43018 commit 7542031

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

llvm/lib/Bitcode/Reader/BitcodeReader.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7333,7 +7333,13 @@ ModuleSummaryIndexBitcodeReader::makeCallList(ArrayRef<uint64_t> Record,
73337333
bool IsOldProfileFormat,
73347334
bool HasProfile, bool HasRelBF) {
73357335
std::vector<FunctionSummary::EdgeTy> Ret;
7336-
Ret.reserve(Record.size());
7336+
// In the case of new profile formats, there are two Record entries per
7337+
// Edge. Otherwise, conservatively reserve up to Record.size.
7338+
if (!IsOldProfileFormat && (HasProfile || HasRelBF))
7339+
Ret.reserve(Record.size() / 2);
7340+
else
7341+
Ret.reserve(Record.size());
7342+
73377343
for (unsigned I = 0, E = Record.size(); I != E; ++I) {
73387344
CalleeInfo::HotnessType Hotness = CalleeInfo::HotnessType::Unknown;
73397345
bool HasTailCall = false;

0 commit comments

Comments
 (0)