mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-04-04 10:30:01 +00:00
llvm-cov: Allow creating CoverageMappings from filenames
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218185 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
9eb38163a5
commit
7df63b7d54
@ -318,11 +318,15 @@ class CoverageMapping {
|
||||
CoverageMapping() : MismatchedFunctionCount(0) {}
|
||||
|
||||
public:
|
||||
/// Load the coverage mapping using the given readers.
|
||||
/// \brief Load the coverage mapping using the given readers.
|
||||
static ErrorOr<std::unique_ptr<CoverageMapping>>
|
||||
load(ObjectFileCoverageMappingReader &CoverageReader,
|
||||
IndexedInstrProfReader &ProfileReader);
|
||||
|
||||
/// \brief Load the coverage mapping from the given files.
|
||||
static ErrorOr<std::unique_ptr<CoverageMapping>>
|
||||
load(StringRef ObjectFilename, StringRef ProfileFilename);
|
||||
|
||||
/// \brief The number of functions that couldn't have their profiles mapped.
|
||||
///
|
||||
/// This is a count of functions whose profile is out of date or otherwise
|
||||
|
@ -183,6 +183,20 @@ CoverageMapping::load(ObjectFileCoverageMappingReader &CoverageReader,
|
||||
return std::move(Coverage);
|
||||
}
|
||||
|
||||
ErrorOr<std::unique_ptr<CoverageMapping>>
|
||||
CoverageMapping::load(StringRef ObjectFilename, StringRef ProfileFilename) {
|
||||
auto CounterMappingBuff = MemoryBuffer::getFileOrSTDIN(ObjectFilename);
|
||||
if (auto EC = CounterMappingBuff.getError())
|
||||
return EC;
|
||||
ObjectFileCoverageMappingReader CoverageReader(CounterMappingBuff.get());
|
||||
if (auto EC = CoverageReader.readHeader())
|
||||
return EC;
|
||||
std::unique_ptr<IndexedInstrProfReader> ProfileReader;
|
||||
if (auto EC = IndexedInstrProfReader::create(ProfileFilename, ProfileReader))
|
||||
return EC;
|
||||
return load(CoverageReader, *ProfileReader);
|
||||
}
|
||||
|
||||
namespace {
|
||||
/// \brief Distributes functions into instantiation sets.
|
||||
///
|
||||
|
@ -196,24 +196,7 @@ CodeCoverageTool::createSourceFileView(StringRef SourceFile,
|
||||
}
|
||||
|
||||
std::unique_ptr<CoverageMapping> CodeCoverageTool::load() {
|
||||
auto CounterMappingBuff = MemoryBuffer::getFileOrSTDIN(ObjectFilename);
|
||||
if (auto EC = CounterMappingBuff.getError()) {
|
||||
error(EC.message(), ObjectFilename);
|
||||
return nullptr;
|
||||
}
|
||||
ObjectFileCoverageMappingReader MappingReader(CounterMappingBuff.get());
|
||||
if (auto EC = MappingReader.readHeader()) {
|
||||
error(EC.message(), ObjectFilename);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::unique_ptr<IndexedInstrProfReader> PGOReader;
|
||||
if (auto EC = IndexedInstrProfReader::create(PGOFilename, PGOReader)) {
|
||||
error(EC.message(), PGOFilename);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto CoverageOrErr = CoverageMapping::load(MappingReader, *PGOReader);
|
||||
auto CoverageOrErr = CoverageMapping::load(ObjectFilename, PGOFilename);
|
||||
if (std::error_code EC = CoverageOrErr.getError()) {
|
||||
colored_ostream(errs(), raw_ostream::RED)
|
||||
<< "error: Failed to load coverage: " << EC.message();
|
||||
|
Loading…
x
Reference in New Issue
Block a user