summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Thornburgh <dthorn@google.com>2023-01-27 12:23:35 -0800
committerTom Stellard <tstellar@redhat.com>2023-02-07 19:00:57 -0800
commitdd08c12f96b40068cecfe0c6b5c613327baf69cf (patch)
tree3bdbd9c3bc9dea0bbe5e25a944fb7bb273656ecf
parent20303e551a5752f7956d7c8fe41fd95426c8ba1e (diff)
downloadllvm-dd08c12f96b40068cecfe0c6b5c613327baf69cf.tar.gz
[llvm-cov] Fix logic error in debuginfod lookup.
Differential Revision: https://reviews.llvm.org/D136702 (cherry picked from commit 9977b65ae240b2cc0dc512fe488b0063e51a517b)
-rw-r--r--llvm/lib/ProfileData/Coverage/CoverageMapping.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp b/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
index 9e3a3d7ba40f..6b7fe1a387bb 100644
--- a/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
+++ b/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
@@ -410,24 +410,30 @@ CoverageMapping::load(ArrayRef<StringRef> ObjectFilenames,
}
if (BIDFetcher) {
- const auto &Compare = [](object::BuildIDRef A, object::BuildIDRef B) {
+ const auto &CompareLT = [](object::BuildIDRef A, object::BuildIDRef B) {
return StringRef(reinterpret_cast<const char *>(A.data()), A.size()) <
StringRef(reinterpret_cast<const char *>(B.data()), B.size());
};
+ const auto &CompareEQ = [](object::BuildIDRef A, object::BuildIDRef B) {
+ return StringRef(reinterpret_cast<const char *>(A.data()), A.size()) ==
+ StringRef(reinterpret_cast<const char *>(B.data()), B.size());
+ };
std::vector<object::BuildID> ProfileBinaryIDs;
if (Error E = ProfileReader->readBinaryIds(ProfileBinaryIDs))
return createFileError(ProfileFilename, std::move(E));
- llvm::sort(ProfileBinaryIDs, Compare);
- std::unique(ProfileBinaryIDs.begin(), ProfileBinaryIDs.end(), Compare);
+ llvm::sort(ProfileBinaryIDs, CompareLT);
+ ProfileBinaryIDs.erase(llvm::unique(ProfileBinaryIDs, CompareEQ),
+ ProfileBinaryIDs.end());
SmallVector<object::BuildIDRef> BinaryIDsToFetch;
if (!ProfileBinaryIDs.empty()) {
- llvm::sort(FoundBinaryIDs, Compare);
- std::unique(FoundBinaryIDs.begin(), FoundBinaryIDs.end(), Compare);
+ llvm::sort(FoundBinaryIDs, CompareLT);
+ FoundBinaryIDs.erase(llvm::unique(FoundBinaryIDs, CompareEQ),
+ FoundBinaryIDs.end());
std::set_difference(
ProfileBinaryIDs.begin(), ProfileBinaryIDs.end(),
FoundBinaryIDs.begin(), FoundBinaryIDs.end(),
- std::inserter(BinaryIDsToFetch, BinaryIDsToFetch.end()), Compare);
+ std::inserter(BinaryIDsToFetch, BinaryIDsToFetch.end()), CompareLT);
}
for (object::BuildIDRef BinaryID : BinaryIDsToFetch) {