diff options
author | Douglas Yung <douglas.yung@sony.com> | 2023-01-25 19:11:08 -0800 |
---|---|---|
committer | Douglas Yung <douglas.yung@sony.com> | 2023-01-25 19:11:08 -0800 |
commit | bce910242e7269446683cfcaffd3ebf5281a9125 (patch) | |
tree | 8b117ac672f868e39ea9f7cf643cf70d66f32473 /llvm/lib/ProfileData/Coverage/CoverageMapping.cpp | |
parent | d4e3a1dcf6494874c1cc4f180c780641593d2ab0 (diff) | |
download | llvm-bce910242e7269446683cfcaffd3ebf5281a9125.zip llvm-bce910242e7269446683cfcaffd3ebf5281a9125.tar.gz llvm-bce910242e7269446683cfcaffd3ebf5281a9125.tar.bz2 |
Revert "[llvm-cov] Look up object files using debuginfod"
This reverts commit efbc8bb18eda63007216ad0cb5a8de04963eddd5.
This change is causing failures when detecting curl on several build bots:
- https://lab.llvm.org/buildbot/#/builders/247/builds/884
- https://lab.llvm.org/buildbot/#/builders/231/builds/7688
- https://lab.llvm.org/buildbot/#/builders/121/builds/27389
- https://lab.llvm.org/buildbot/#/builders/230/builds/8464
- https://lab.llvm.org/buildbot/#/builders/57/builds/24209
- https://lab.llvm.org/buildbot/#/builders/127/builds/42722
Diffstat (limited to 'llvm/lib/ProfileData/Coverage/CoverageMapping.cpp')
-rw-r--r-- | llvm/lib/ProfileData/Coverage/CoverageMapping.cpp | 113 |
1 files changed, 26 insertions, 87 deletions
diff --git a/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp b/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp index 52cb577..6113f78 100644 --- a/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp +++ b/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp @@ -17,7 +17,6 @@ #include "llvm/ADT/SmallBitVector.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" -#include "llvm/Object/BuildID.h" #include "llvm/ProfileData/Coverage/CoverageMappingReader.h" #include "llvm/ProfileData/InstrProfReader.h" #include "llvm/Support/Debug.h" @@ -343,49 +342,10 @@ static Error handleMaybeNoDataFoundError(Error E) { }); } -Error CoverageMapping::loadFromFile( - StringRef Filename, StringRef Arch, StringRef CompilationDir, - IndexedInstrProfReader &ProfileReader, CoverageMapping &Coverage, - bool &DataFound, SmallVectorImpl<object::BuildID> *FoundBinaryIDs) { - auto CovMappingBufOrErr = MemoryBuffer::getFileOrSTDIN( - Filename, /*IsText=*/false, /*RequiresNullTerminator=*/false); - if (std::error_code EC = CovMappingBufOrErr.getError()) - return createFileError(Filename, errorCodeToError(EC)); - MemoryBufferRef CovMappingBufRef = - CovMappingBufOrErr.get()->getMemBufferRef(); - SmallVector<std::unique_ptr<MemoryBuffer>, 4> Buffers; - - SmallVector<object::BuildIDRef> BinaryIDs; - auto CoverageReadersOrErr = BinaryCoverageReader::create( - CovMappingBufRef, Arch, Buffers, CompilationDir, - FoundBinaryIDs ? &BinaryIDs : nullptr); - if (Error E = CoverageReadersOrErr.takeError()) { - E = handleMaybeNoDataFoundError(std::move(E)); - if (E) - return createFileError(Filename, std::move(E)); - return E; - } - - SmallVector<std::unique_ptr<CoverageMappingReader>, 4> Readers; - for (auto &Reader : CoverageReadersOrErr.get()) - Readers.push_back(std::move(Reader)); - if (FoundBinaryIDs && !Readers.empty()) { - llvm::append_range(*FoundBinaryIDs, - llvm::map_range(BinaryIDs, [](object::BuildIDRef BID) { - return object::BuildID(BID); - })); - } - DataFound |= !Readers.empty(); - if (Error E = loadFromReaders(Readers, ProfileReader, Coverage)) - return createFileError(Filename, std::move(E)); - return Error::success(); -} - Expected<std::unique_ptr<CoverageMapping>> CoverageMapping::load(ArrayRef<StringRef> ObjectFilenames, StringRef ProfileFilename, ArrayRef<StringRef> Arches, - StringRef CompilationDir, - const object::BuildIDFetcher *BIDFetcher) { + StringRef CompilationDir) { auto ProfileReaderOrErr = IndexedInstrProfReader::create(ProfileFilename); if (Error E = ProfileReaderOrErr.takeError()) return createFileError(ProfileFilename, std::move(E)); @@ -393,56 +353,35 @@ CoverageMapping::load(ArrayRef<StringRef> ObjectFilenames, auto Coverage = std::unique_ptr<CoverageMapping>(new CoverageMapping()); bool DataFound = false; - auto GetArch = [&](size_t Idx) { - if (Arches.empty()) - return StringRef(); - if (Arches.size() == 1) - return Arches.front(); - return Arches[Idx]; - }; - - SmallVector<object::BuildID> FoundBinaryIDs; for (const auto &File : llvm::enumerate(ObjectFilenames)) { - if (Error E = - loadFromFile(File.value(), GetArch(File.index()), CompilationDir, - *ProfileReader, *Coverage, DataFound, &FoundBinaryIDs)) - return E; - } - - if (BIDFetcher) { - const auto &Compare = [](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); - - SmallVector<object::BuildIDRef> BinaryIDsToFetch; - if (!ProfileBinaryIDs.empty()) { - llvm::sort(FoundBinaryIDs, Compare); - std::unique(FoundBinaryIDs.begin(), FoundBinaryIDs.end(), Compare); - std::set_difference( - ProfileBinaryIDs.begin(), ProfileBinaryIDs.end(), - FoundBinaryIDs.begin(), FoundBinaryIDs.end(), - std::inserter(BinaryIDsToFetch, BinaryIDsToFetch.end()), Compare); + auto CovMappingBufOrErr = MemoryBuffer::getFileOrSTDIN( + File.value(), /*IsText=*/false, /*RequiresNullTerminator=*/false); + if (std::error_code EC = CovMappingBufOrErr.getError()) + return createFileError(File.value(), errorCodeToError(EC)); + StringRef Arch = Arches.empty() ? StringRef() : Arches[File.index()]; + MemoryBufferRef CovMappingBufRef = + CovMappingBufOrErr.get()->getMemBufferRef(); + SmallVector<std::unique_ptr<MemoryBuffer>, 4> Buffers; + auto CoverageReadersOrErr = BinaryCoverageReader::create( + CovMappingBufRef, Arch, Buffers, CompilationDir); + if (Error E = CoverageReadersOrErr.takeError()) { + E = handleMaybeNoDataFoundError(std::move(E)); + if (E) + return createFileError(File.value(), std::move(E)); + // E == success (originally a no_data_found error). + continue; } - for (object::BuildIDRef BinaryID : BinaryIDsToFetch) { - std::optional<std::string> PathOpt = BIDFetcher->fetch(BinaryID); - if (!PathOpt) - continue; - std::string Path = std::move(*PathOpt); - StringRef Arch = Arches.size() == 1 ? Arches.front() : StringRef(); - if (Error E = loadFromFile(Path, Arch, CompilationDir, *ProfileReader, - *Coverage, DataFound)) - return E; - } + SmallVector<std::unique_ptr<CoverageMappingReader>, 4> Readers; + for (auto &Reader : CoverageReadersOrErr.get()) + Readers.push_back(std::move(Reader)); + DataFound |= !Readers.empty(); + if (Error E = loadFromReaders(Readers, *ProfileReader, *Coverage)) + return createFileError(File.value(), std::move(E)); } - - if (!DataFound) + // If no readers were created, either no objects were provided or none of them + // had coverage data. Return an error in the latter case. + if (!DataFound && !ObjectFilenames.empty()) return createFileError( join(ObjectFilenames.begin(), ObjectFilenames.end(), ", "), make_error<CoverageMapError>(coveragemap_error::no_data_found)); |