diff options
author | Daniel Thornburgh <dthorn@google.com> | 2023-01-27 12:23:35 -0800 |
---|---|---|
committer | Daniel Thornburgh <dthorn@google.com> | 2023-01-27 12:24:19 -0800 |
commit | 9977b65ae240b2cc0dc512fe488b0063e51a517b (patch) | |
tree | e9d4897c6603ae6e9489710e5108c3b9f3052d97 /llvm/lib/ProfileData/Coverage/CoverageMapping.cpp | |
parent | feedb4ad7d305c5864127e2b27ae650e8f04fc58 (diff) | |
download | llvm-9977b65ae240b2cc0dc512fe488b0063e51a517b.zip llvm-9977b65ae240b2cc0dc512fe488b0063e51a517b.tar.gz llvm-9977b65ae240b2cc0dc512fe488b0063e51a517b.tar.bz2 |
[llvm-cov] Fix logic error in debuginfod lookup.
Differential Revision: https://reviews.llvm.org/D136702
Diffstat (limited to 'llvm/lib/ProfileData/Coverage/CoverageMapping.cpp')
-rw-r--r-- | llvm/lib/ProfileData/Coverage/CoverageMapping.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp b/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp index 9e3a3d7..6b7fe1a 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) { |