aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp')
-rw-r--r--llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp67
1 files changed, 20 insertions, 47 deletions
diff --git a/llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp b/llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp
index b17caaf..e468fbf 100644
--- a/llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp
+++ b/llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp
@@ -25,7 +25,6 @@
#include "llvm/Object/MachOUniversal.h"
#include "llvm/Object/ObjectFile.h"
#include "llvm/ProfileData/InstrProf.h"
-#include "llvm/ProfileData/InstrProfReader.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Compression.h"
#include "llvm/Support/Debug.h"
@@ -1022,23 +1021,9 @@ static Expected<std::vector<SectionRef>> lookupSections(ObjectFile &OF,
return Sections;
}
-static Error getProfileNamesFromDebugInfo(StringRef FileName,
- InstrProfSymtab &ProfileNames) {
- std::unique_ptr<InstrProfCorrelator> Correlator;
- if (auto E = InstrProfCorrelator::get(FileName).moveInto(Correlator))
- return E;
- if (auto E = Correlator->correlateCovUnusedFuncNames(0))
- return E;
- if (auto E = ProfileNames.create(
- StringRef(Correlator->getCovUnusedFuncNamesPointer(),
- Correlator->getCovUnusedFuncNamesSize())))
- return E;
- return Error::success();
-}
-
static Expected<std::unique_ptr<BinaryCoverageReader>>
loadBinaryFormat(std::unique_ptr<Binary> Bin, StringRef Arch,
- InstrProfSymtab &ProfSymTab, StringRef CompilationDir = "",
+ StringRef CompilationDir = "",
object::BuildIDRef *BinaryID = nullptr) {
std::unique_ptr<ObjectFile> OF;
if (auto *Universal = dyn_cast<MachOUniversalBinary>(Bin.get())) {
@@ -1067,30 +1052,11 @@ loadBinaryFormat(std::unique_ptr<Binary> Bin, StringRef Arch,
// Look for the sections that we are interested in.
auto ObjFormat = OF->getTripleObjectFormat();
- // Without debug info correlation, all function names are stored in the
- // binary's profile name section.
- // When debug info correlation is enabled, instrumented function names are
- // stored in the indexed profile file, and unused function names are stored in
- // the binary's debug info.
- InstrProfSymtab ProfileNames = ProfSymTab;
auto NamesSection =
lookupSections(*OF, getInstrProfSectionName(IPSK_name, ObjFormat,
- /*AddSegmentInfo=*/false));
- if (auto E = NamesSection.takeError()) {
- if (OF->hasDebugInfo()) {
- if (auto E =
- getProfileNamesFromDebugInfo(OF->getFileName(), ProfileNames))
- return make_error<CoverageMapError>(coveragemap_error::malformed);
- }
- consumeError(std::move(E));
- } else {
- std::vector<SectionRef> NamesSectionRefs = *NamesSection;
- if (NamesSectionRefs.size() != 1)
- return make_error<CoverageMapError>(coveragemap_error::malformed);
- if (Error E = ProfileNames.create(NamesSectionRefs.back()))
- return std::move(E);
- }
-
+ /*AddSegmentInfo=*/false));
+ if (auto E = NamesSection.takeError())
+ return std::move(E);
auto CoverageSection =
lookupSections(*OF, getInstrProfSectionName(IPSK_covmap, ObjFormat,
/*AddSegmentInfo=*/false));
@@ -1105,6 +1071,15 @@ loadBinaryFormat(std::unique_ptr<Binary> Bin, StringRef Arch,
return CoverageMappingOrErr.takeError();
StringRef CoverageMapping = CoverageMappingOrErr.get();
+ InstrProfSymtab ProfileNames;
+ std::vector<SectionRef> NamesSectionRefs = *NamesSection;
+ if (NamesSectionRefs.size() != 1)
+ return make_error<CoverageMapError>(
+ coveragemap_error::malformed,
+ "the size of coverage mapping section is not one");
+ if (Error E = ProfileNames.create(NamesSectionRefs.back()))
+ return std::move(E);
+
// Look for the coverage records section (Version4 only).
auto CoverageRecordsSections =
lookupSections(*OF, getInstrProfSectionName(IPSK_covfun, ObjFormat,
@@ -1176,8 +1151,7 @@ Expected<std::vector<std::unique_ptr<BinaryCoverageReader>>>
BinaryCoverageReader::create(
MemoryBufferRef ObjectBuffer, StringRef Arch,
SmallVectorImpl<std::unique_ptr<MemoryBuffer>> &ObjectFileBuffers,
- InstrProfSymtab &ProfSymTab, StringRef CompilationDir,
- SmallVectorImpl<object::BuildIDRef> *BinaryIDs) {
+ StringRef CompilationDir, SmallVectorImpl<object::BuildIDRef> *BinaryIDs) {
std::vector<std::unique_ptr<BinaryCoverageReader>> Readers;
if (ObjectBuffer.getBuffer().size() > sizeof(TestingFormatMagic)) {
@@ -1221,8 +1195,8 @@ BinaryCoverageReader::create(
}
return BinaryCoverageReader::create(
- ArchiveOrErr.get()->getMemoryBufferRef(), Arch,
- ObjectFileBuffers, ProfSymTab, CompilationDir, BinaryIDs);
+ ArchiveOrErr.get()->getMemoryBufferRef(), Arch, ObjectFileBuffers,
+ CompilationDir, BinaryIDs);
}
}
@@ -1235,8 +1209,8 @@ BinaryCoverageReader::create(
return ChildBufOrErr.takeError();
auto ChildReadersOrErr = BinaryCoverageReader::create(
- ChildBufOrErr.get(), Arch, ObjectFileBuffers, ProfSymTab,
- CompilationDir, BinaryIDs);
+ ChildBufOrErr.get(), Arch, ObjectFileBuffers, CompilationDir,
+ BinaryIDs);
if (!ChildReadersOrErr)
return ChildReadersOrErr.takeError();
for (auto &Reader : ChildReadersOrErr.get())
@@ -1256,9 +1230,8 @@ BinaryCoverageReader::create(
}
object::BuildIDRef BinaryID;
- auto ReaderOrErr =
- loadBinaryFormat(std::move(Bin), Arch, ProfSymTab, CompilationDir,
- BinaryIDs ? &BinaryID : nullptr);
+ auto ReaderOrErr = loadBinaryFormat(std::move(Bin), Arch, CompilationDir,
+ BinaryIDs ? &BinaryID : nullptr);
if (!ReaderOrErr)
return ReaderOrErr.takeError();
Readers.push_back(std::move(ReaderOrErr.get()));