[llvm] 15135af - [memprof] Use a SetVector (NFC) (#93312)
via llvm-commits
llvm-commits at lists.llvm.org
Fri May 24 09:02:56 PDT 2024
Author: Kazu Hirata
Date: 2024-05-24T09:02:53-07:00
New Revision: 15135afad15cbcfaaa395d364d9f2ca1f48f2948
URL: https://github.com/llvm/llvm-project/commit/15135afad15cbcfaaa395d364d9f2ca1f48f2948
DIFF: https://github.com/llvm/llvm-project/commit/15135afad15cbcfaaa395d364d9f2ca1f48f2948.diff
LOG: [memprof] Use a SetVector (NFC) (#93312)
Added:
Modified:
llvm/lib/ProfileData/MemProfReader.cpp
Removed:
################################################################################
diff --git a/llvm/lib/ProfileData/MemProfReader.cpp b/llvm/lib/ProfileData/MemProfReader.cpp
index c25babac844ac..fc3be716087eb 100644
--- a/llvm/lib/ProfileData/MemProfReader.cpp
+++ b/llvm/lib/ProfileData/MemProfReader.cpp
@@ -587,31 +587,27 @@ Error RawMemProfReader::symbolizeAndFilterStackFrames(
std::vector<std::string>
RawMemProfReader::peekBuildIds(MemoryBuffer *DataBuffer) {
const char *Next = DataBuffer->getBufferStart();
- // Use a set + vector since a profile file may contain multiple raw profile
+ // Use a SetVector since a profile file may contain multiple raw profile
// dumps, each with segment information. We want them unique and in order they
// were stored in the profile; the profiled binary should be the first entry.
// The runtime uses dl_iterate_phdr and the "... first object visited by
// callback is the main program."
// https://man7.org/linux/man-pages/man3/dl_iterate_phdr.3.html
- std::vector<std::string> BuildIds;
- llvm::SmallSet<std::string, 10> BuildIdsSet;
+ llvm::SetVector<std::string, std::vector<std::string>,
+ llvm::SmallSet<std::string, 10>>
+ BuildIds;
while (Next < DataBuffer->getBufferEnd()) {
auto *Header = reinterpret_cast<const memprof::Header *>(Next);
const llvm::SmallVector<SegmentEntry> Entries =
readSegmentEntries(Next + Header->SegmentOffset);
- for (const auto &Entry : Entries) {
- const std::string Id = getBuildIdString(Entry);
- if (BuildIdsSet.contains(Id))
- continue;
- BuildIds.push_back(Id);
- BuildIdsSet.insert(Id);
- }
+ for (const auto &Entry : Entries)
+ BuildIds.insert(getBuildIdString(Entry));
Next += Header->TotalSize;
}
- return BuildIds;
+ return BuildIds.takeVector();
}
Error RawMemProfReader::readRawProfile(
More information about the llvm-commits
mailing list