Skip to content

Commit 65d88d3

Browse files
authored
Revert "[llvm-cov] Add support for baseline coverage" (#144121)
Reverts #117910 ``` /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/llvm/unittests/ProfileData/CoverageMappingTest.cpp /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/llvm/unittests/ProfileData/CoverageMappingTest.cpp:281:28: error: 'std::reference_wrapper' may not intend to support class template argument deduction [-Werror,-Wctad-maybe-unsupported] 281 | std::make_optional(std::reference_wrapper(*ProfileReader)); | ^ /usr/lib/gcc/ppc64le-redhat-linux/8/../../../../include/c++/8/bits/refwrap.h:289:11: note: add a deduction guide to suppress this warning 289 | class reference_wrapper | ^ ```
1 parent 2704b27 commit 65d88d3

File tree

6 files changed

+86
-195
lines changed

6 files changed

+86
-195
lines changed

llvm/docs/CommandGuide/llvm-cov.rst

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -380,11 +380,6 @@ OPTIONS
380380
Fail if an object file cannot be found for a binary ID present in the profile,
381381
neither on the command line nor via binary ID lookup.
382382

383-
.. option:: -empty-profile
384-
385-
Display the baseline coverage of the binaries with all zero execution counts.
386-
Mutually exclusive with -instr-profile.
387-
388383
.. program:: llvm-cov report
389384

390385
.. _llvm-cov-report:
@@ -475,11 +470,6 @@ OPTIONS
475470
Fail if an object file cannot be found for a binary ID present in the profile,
476471
neither on the command line nor via binary ID lookup.
477472

478-
.. option:: -empty-profile
479-
480-
Display the baseline coverage of the binaries with all zero execution counts.
481-
Mutually exclusive with -instr-profile.
482-
483473
.. program:: llvm-cov export
484474

485475
.. _llvm-cov-export:
@@ -572,11 +562,6 @@ OPTIONS
572562
Fail if an object file cannot be found for a binary ID present in the profile,
573563
neither on the command line nor via binary ID lookup.
574564

575-
.. option:: -empty-profile
576-
577-
Export the baseline coverage of the binaries with all zero execution counts.
578-
Mutually exclusive with -instr-profile.
579-
580565
CONVERT-FOR-TESTING COMMAND
581566
---------------------------
582567

llvm/include/llvm/ProfileData/Coverage/CoverageMapping.h

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -991,23 +991,18 @@ class CoverageMapping {
991991
// Load coverage records from readers.
992992
static Error loadFromReaders(
993993
ArrayRef<std::unique_ptr<CoverageMappingReader>> CoverageReaders,
994-
std::optional<std::reference_wrapper<IndexedInstrProfReader>>
995-
&ProfileReader,
996-
CoverageMapping &Coverage);
994+
IndexedInstrProfReader &ProfileReader, CoverageMapping &Coverage);
997995

998996
// Load coverage records from file.
999997
static Error
1000998
loadFromFile(StringRef Filename, StringRef Arch, StringRef CompilationDir,
1001-
std::optional<std::reference_wrapper<IndexedInstrProfReader>>
1002-
&ProfileReader,
1003-
CoverageMapping &Coverage, bool &DataFound,
999+
IndexedInstrProfReader &ProfileReader, CoverageMapping &Coverage,
1000+
bool &DataFound,
10041001
SmallVectorImpl<object::BuildID> *FoundBinaryIDs = nullptr);
10051002

10061003
/// Add a function record corresponding to \p Record.
1007-
Error loadFunctionRecord(
1008-
const CoverageMappingRecord &Record,
1009-
const std::optional<std::reference_wrapper<IndexedInstrProfReader>>
1010-
&ProfileReader);
1004+
Error loadFunctionRecord(const CoverageMappingRecord &Record,
1005+
IndexedInstrProfReader &ProfileReader);
10111006

10121007
/// Look up the indices for function records which are at least partially
10131008
/// defined in the specified file. This is guaranteed to return a superset of
@@ -1023,16 +1018,15 @@ class CoverageMapping {
10231018
/// Load the coverage mapping using the given readers.
10241019
LLVM_ABI static Expected<std::unique_ptr<CoverageMapping>>
10251020
load(ArrayRef<std::unique_ptr<CoverageMappingReader>> CoverageReaders,
1026-
std::optional<std::reference_wrapper<IndexedInstrProfReader>>
1027-
&ProfileReader);
1021+
IndexedInstrProfReader &ProfileReader);
10281022

10291023
/// Load the coverage mapping from the given object files and profile. If
10301024
/// \p Arches is non-empty, it must specify an architecture for each object.
10311025
/// Ignores non-instrumented object files unless all are not instrumented.
10321026
LLVM_ABI static Expected<std::unique_ptr<CoverageMapping>>
1033-
load(ArrayRef<StringRef> ObjectFilenames,
1034-
std::optional<StringRef> ProfileFilename, vfs::FileSystem &FS,
1035-
ArrayRef<StringRef> Arches = {}, StringRef CompilationDir = "",
1027+
load(ArrayRef<StringRef> ObjectFilenames, StringRef ProfileFilename,
1028+
vfs::FileSystem &FS, ArrayRef<StringRef> Arches = {},
1029+
StringRef CompilationDir = "",
10361030
const object::BuildIDFetcher *BIDFetcher = nullptr,
10371031
bool CheckBinaryIDs = false);
10381032

llvm/lib/ProfileData/Coverage/CoverageMapping.cpp

Lines changed: 48 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -823,8 +823,7 @@ class MCDCDecisionRecorder {
823823

824824
Error CoverageMapping::loadFunctionRecord(
825825
const CoverageMappingRecord &Record,
826-
const std::optional<std::reference_wrapper<IndexedInstrProfReader>>
827-
&ProfileReader) {
826+
IndexedInstrProfReader &ProfileReader) {
828827
StringRef OrigFuncName = Record.FunctionName;
829828
if (OrigFuncName.empty())
830829
return make_error<CoverageMapError>(coveragemap_error::malformed,
@@ -838,44 +837,35 @@ Error CoverageMapping::loadFunctionRecord(
838837
CounterMappingContext Ctx(Record.Expressions);
839838

840839
std::vector<uint64_t> Counts;
841-
if (ProfileReader) {
842-
if (Error E = ProfileReader.value().get().getFunctionCounts(
843-
Record.FunctionName, Record.FunctionHash, Counts)) {
844-
instrprof_error IPE = std::get<0>(InstrProfError::take(std::move(E)));
845-
if (IPE == instrprof_error::hash_mismatch) {
846-
FuncHashMismatches.emplace_back(std::string(Record.FunctionName),
847-
Record.FunctionHash);
848-
return Error::success();
849-
}
850-
if (IPE != instrprof_error::unknown_function)
851-
return make_error<InstrProfError>(IPE);
852-
Counts.assign(getMaxCounterID(Ctx, Record) + 1, 0);
840+
if (Error E = ProfileReader.getFunctionCounts(Record.FunctionName,
841+
Record.FunctionHash, Counts)) {
842+
instrprof_error IPE = std::get<0>(InstrProfError::take(std::move(E)));
843+
if (IPE == instrprof_error::hash_mismatch) {
844+
FuncHashMismatches.emplace_back(std::string(Record.FunctionName),
845+
Record.FunctionHash);
846+
return Error::success();
853847
}
854-
} else {
848+
if (IPE != instrprof_error::unknown_function)
849+
return make_error<InstrProfError>(IPE);
855850
Counts.assign(getMaxCounterID(Ctx, Record) + 1, 0);
856851
}
857852
Ctx.setCounts(Counts);
858853

859854
bool IsVersion11 =
860-
ProfileReader && ProfileReader.value().get().getVersion() <
861-
IndexedInstrProf::ProfVersion::Version12;
855+
ProfileReader.getVersion() < IndexedInstrProf::ProfVersion::Version12;
862856

863857
BitVector Bitmap;
864-
if (ProfileReader) {
865-
if (Error E = ProfileReader.value().get().getFunctionBitmap(
866-
Record.FunctionName, Record.FunctionHash, Bitmap)) {
867-
instrprof_error IPE = std::get<0>(InstrProfError::take(std::move(E)));
868-
if (IPE == instrprof_error::hash_mismatch) {
869-
FuncHashMismatches.emplace_back(std::string(Record.FunctionName),
870-
Record.FunctionHash);
871-
return Error::success();
872-
}
873-
if (IPE != instrprof_error::unknown_function)
874-
return make_error<InstrProfError>(IPE);
875-
Bitmap = BitVector(getMaxBitmapSize(Record, IsVersion11));
858+
if (Error E = ProfileReader.getFunctionBitmap(Record.FunctionName,
859+
Record.FunctionHash, Bitmap)) {
860+
instrprof_error IPE = std::get<0>(InstrProfError::take(std::move(E)));
861+
if (IPE == instrprof_error::hash_mismatch) {
862+
FuncHashMismatches.emplace_back(std::string(Record.FunctionName),
863+
Record.FunctionHash);
864+
return Error::success();
876865
}
877-
} else {
878-
Bitmap = BitVector(getMaxBitmapSize(Record, false));
866+
if (IPE != instrprof_error::unknown_function)
867+
return make_error<InstrProfError>(IPE);
868+
Bitmap = BitVector(getMaxBitmapSize(Record, IsVersion11));
879869
}
880870
Ctx.setBitmap(std::move(Bitmap));
881871

@@ -969,14 +959,10 @@ Error CoverageMapping::loadFunctionRecord(
969959
// of CoverageMappingReader instances.
970960
Error CoverageMapping::loadFromReaders(
971961
ArrayRef<std::unique_ptr<CoverageMappingReader>> CoverageReaders,
972-
std::optional<std::reference_wrapper<IndexedInstrProfReader>>
973-
&ProfileReader,
974-
CoverageMapping &Coverage) {
975-
assert(!Coverage.SingleByteCoverage || !ProfileReader ||
976-
*Coverage.SingleByteCoverage ==
977-
ProfileReader.value().get().hasSingleByteCoverage());
978-
Coverage.SingleByteCoverage =
979-
!ProfileReader || ProfileReader.value().get().hasSingleByteCoverage();
962+
IndexedInstrProfReader &ProfileReader, CoverageMapping &Coverage) {
963+
assert(!Coverage.SingleByteCoverage ||
964+
*Coverage.SingleByteCoverage == ProfileReader.hasSingleByteCoverage());
965+
Coverage.SingleByteCoverage = ProfileReader.hasSingleByteCoverage();
980966
for (const auto &CoverageReader : CoverageReaders) {
981967
for (auto RecordOrErr : *CoverageReader) {
982968
if (Error E = RecordOrErr.takeError())
@@ -991,8 +977,7 @@ Error CoverageMapping::loadFromReaders(
991977

992978
Expected<std::unique_ptr<CoverageMapping>> CoverageMapping::load(
993979
ArrayRef<std::unique_ptr<CoverageMappingReader>> CoverageReaders,
994-
std::optional<std::reference_wrapper<IndexedInstrProfReader>>
995-
&ProfileReader) {
980+
IndexedInstrProfReader &ProfileReader) {
996981
auto Coverage = std::unique_ptr<CoverageMapping>(new CoverageMapping());
997982
if (Error E = loadFromReaders(CoverageReaders, ProfileReader, *Coverage))
998983
return std::move(E);
@@ -1001,19 +986,18 @@ Expected<std::unique_ptr<CoverageMapping>> CoverageMapping::load(
1001986

1002987
// If E is a no_data_found error, returns success. Otherwise returns E.
1003988
static Error handleMaybeNoDataFoundError(Error E) {
1004-
return handleErrors(std::move(E), [](const CoverageMapError &CME) {
1005-
if (CME.get() == coveragemap_error::no_data_found)
1006-
return static_cast<Error>(Error::success());
1007-
return make_error<CoverageMapError>(CME.get(), CME.getMessage());
1008-
});
989+
return handleErrors(
990+
std::move(E), [](const CoverageMapError &CME) {
991+
if (CME.get() == coveragemap_error::no_data_found)
992+
return static_cast<Error>(Error::success());
993+
return make_error<CoverageMapError>(CME.get(), CME.getMessage());
994+
});
1009995
}
1010996

1011997
Error CoverageMapping::loadFromFile(
1012998
StringRef Filename, StringRef Arch, StringRef CompilationDir,
1013-
std::optional<std::reference_wrapper<IndexedInstrProfReader>>
1014-
&ProfileReader,
1015-
CoverageMapping &Coverage, bool &DataFound,
1016-
SmallVectorImpl<object::BuildID> *FoundBinaryIDs) {
999+
IndexedInstrProfReader &ProfileReader, CoverageMapping &Coverage,
1000+
bool &DataFound, SmallVectorImpl<object::BuildID> *FoundBinaryIDs) {
10171001
auto CovMappingBufOrErr = MemoryBuffer::getFileOrSTDIN(
10181002
Filename, /*IsText=*/false, /*RequiresNullTerminator=*/false);
10191003
if (std::error_code EC = CovMappingBufOrErr.getError())
@@ -1049,23 +1033,13 @@ Error CoverageMapping::loadFromFile(
10491033
}
10501034

10511035
Expected<std::unique_ptr<CoverageMapping>> CoverageMapping::load(
1052-
ArrayRef<StringRef> ObjectFilenames,
1053-
std::optional<StringRef> ProfileFilename, vfs::FileSystem &FS,
1054-
ArrayRef<StringRef> Arches, StringRef CompilationDir,
1036+
ArrayRef<StringRef> ObjectFilenames, StringRef ProfileFilename,
1037+
vfs::FileSystem &FS, ArrayRef<StringRef> Arches, StringRef CompilationDir,
10551038
const object::BuildIDFetcher *BIDFetcher, bool CheckBinaryIDs) {
1056-
std::unique_ptr<IndexedInstrProfReader> ProfileReader;
1057-
if (ProfileFilename) {
1058-
auto ProfileReaderOrErr =
1059-
IndexedInstrProfReader::create(ProfileFilename.value(), FS);
1060-
if (Error E = ProfileReaderOrErr.takeError())
1061-
return createFileError(ProfileFilename.value(), std::move(E));
1062-
ProfileReader = std::move(ProfileReaderOrErr.get());
1063-
}
1064-
auto ProfileReaderRef =
1065-
ProfileReader
1066-
? std::optional<std::reference_wrapper<IndexedInstrProfReader>>(
1067-
*ProfileReader)
1068-
: std::nullopt;
1039+
auto ProfileReaderOrErr = IndexedInstrProfReader::create(ProfileFilename, FS);
1040+
if (Error E = ProfileReaderOrErr.takeError())
1041+
return createFileError(ProfileFilename, std::move(E));
1042+
auto ProfileReader = std::move(ProfileReaderOrErr.get());
10691043
auto Coverage = std::unique_ptr<CoverageMapping>(new CoverageMapping());
10701044
bool DataFound = false;
10711045

@@ -1079,17 +1053,16 @@ Expected<std::unique_ptr<CoverageMapping>> CoverageMapping::load(
10791053

10801054
SmallVector<object::BuildID> FoundBinaryIDs;
10811055
for (const auto &File : llvm::enumerate(ObjectFilenames)) {
1082-
if (Error E = loadFromFile(File.value(), GetArch(File.index()),
1083-
CompilationDir, ProfileReaderRef, *Coverage,
1084-
DataFound, &FoundBinaryIDs))
1056+
if (Error E =
1057+
loadFromFile(File.value(), GetArch(File.index()), CompilationDir,
1058+
*ProfileReader, *Coverage, DataFound, &FoundBinaryIDs))
10851059
return std::move(E);
10861060
}
10871061

10881062
if (BIDFetcher) {
10891063
std::vector<object::BuildID> ProfileBinaryIDs;
1090-
if (ProfileReader)
1091-
if (Error E = ProfileReader->readBinaryIds(ProfileBinaryIDs))
1092-
return createFileError(ProfileFilename.value(), std::move(E));
1064+
if (Error E = ProfileReader->readBinaryIds(ProfileBinaryIDs))
1065+
return createFileError(ProfileFilename, std::move(E));
10931066

10941067
SmallVector<object::BuildIDRef> BinaryIDsToFetch;
10951068
if (!ProfileBinaryIDs.empty()) {
@@ -1109,12 +1082,12 @@ Expected<std::unique_ptr<CoverageMapping>> CoverageMapping::load(
11091082
if (PathOpt) {
11101083
std::string Path = std::move(*PathOpt);
11111084
StringRef Arch = Arches.size() == 1 ? Arches.front() : StringRef();
1112-
if (Error E = loadFromFile(Path, Arch, CompilationDir, ProfileReaderRef,
1113-
*Coverage, DataFound))
1085+
if (Error E = loadFromFile(Path, Arch, CompilationDir, *ProfileReader,
1086+
*Coverage, DataFound))
11141087
return std::move(E);
11151088
} else if (CheckBinaryIDs) {
11161089
return createFileError(
1117-
ProfileFilename.value(),
1090+
ProfileFilename,
11181091
createStringError(errc::no_such_file_or_directory,
11191092
"Missing binary ID: " +
11201093
llvm::toHex(BinaryID, /*LowerCase=*/true)));

llvm/test/tools/llvm-cov/showLineExecutionCounts-lcov-baseline.test

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)