Skip to content

Commit 15135af

Browse files
[memprof] Use a SetVector (NFC) (#93312)
1 parent 9ad5da2 commit 15135af

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

llvm/lib/ProfileData/MemProfReader.cpp

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -587,31 +587,27 @@ Error RawMemProfReader::symbolizeAndFilterStackFrames(
587587
std::vector<std::string>
588588
RawMemProfReader::peekBuildIds(MemoryBuffer *DataBuffer) {
589589
const char *Next = DataBuffer->getBufferStart();
590-
// Use a set + vector since a profile file may contain multiple raw profile
590+
// Use a SetVector since a profile file may contain multiple raw profile
591591
// dumps, each with segment information. We want them unique and in order they
592592
// were stored in the profile; the profiled binary should be the first entry.
593593
// The runtime uses dl_iterate_phdr and the "... first object visited by
594594
// callback is the main program."
595595
// https://man7.org/linux/man-pages/man3/dl_iterate_phdr.3.html
596-
std::vector<std::string> BuildIds;
597-
llvm::SmallSet<std::string, 10> BuildIdsSet;
596+
llvm::SetVector<std::string, std::vector<std::string>,
597+
llvm::SmallSet<std::string, 10>>
598+
BuildIds;
598599
while (Next < DataBuffer->getBufferEnd()) {
599600
auto *Header = reinterpret_cast<const memprof::Header *>(Next);
600601

601602
const llvm::SmallVector<SegmentEntry> Entries =
602603
readSegmentEntries(Next + Header->SegmentOffset);
603604

604-
for (const auto &Entry : Entries) {
605-
const std::string Id = getBuildIdString(Entry);
606-
if (BuildIdsSet.contains(Id))
607-
continue;
608-
BuildIds.push_back(Id);
609-
BuildIdsSet.insert(Id);
610-
}
605+
for (const auto &Entry : Entries)
606+
BuildIds.insert(getBuildIdString(Entry));
611607

612608
Next += Header->TotalSize;
613609
}
614-
return BuildIds;
610+
return BuildIds.takeVector();
615611
}
616612

617613
Error RawMemProfReader::readRawProfile(

0 commit comments

Comments
 (0)