Skip to content

Commit 4d5d9a5

Browse files
committed
Revert "[Coverage] Allow Clang coverage to be used with debug info correlation."
This reverts commit 32db121 and subsequent commits. This causes time regression on llvm-cov even with debug info correlation off.
1 parent 58f7543 commit 4d5d9a5

File tree

11 files changed

+23
-339
lines changed

11 files changed

+23
-339
lines changed

clang/lib/CodeGen/CoverageMappingGen.cpp

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@
3131
// is textually included.
3232
#define COVMAP_V3
3333

34-
namespace llvm {
35-
extern cl::opt<bool> DebugInfoCorrelate;
36-
} // namespace llvm
37-
3834
static llvm::cl::opt<bool> EmptyLineCommentCoverage(
3935
"emptyline-comment-coverage",
4036
llvm::cl::desc("Emit emptylines and comment lines as skipped regions (only "
@@ -1835,22 +1831,6 @@ void CoverageMappingModuleGen::emit() {
18351831
llvm::GlobalValue::InternalLinkage, NamesArrVal,
18361832
llvm::getCoverageUnusedNamesVarName());
18371833
}
1838-
const StringRef VarName(INSTR_PROF_QUOTE(INSTR_PROF_RAW_VERSION_VAR));
1839-
llvm::Type *IntTy64 = llvm::Type::getInt64Ty(Ctx);
1840-
uint64_t ProfileVersion = INSTR_PROF_RAW_VERSION;
1841-
if (llvm::DebugInfoCorrelate)
1842-
ProfileVersion |= VARIANT_MASK_DBG_CORRELATE;
1843-
auto *VersionVariable = new llvm::GlobalVariable(
1844-
CGM.getModule(), llvm::Type::getInt64Ty(Ctx), true,
1845-
llvm::GlobalValue::WeakAnyLinkage,
1846-
llvm::Constant::getIntegerValue(IntTy64, llvm::APInt(64, ProfileVersion)),
1847-
VarName);
1848-
VersionVariable->setVisibility(llvm::GlobalValue::HiddenVisibility);
1849-
llvm::Triple TT(CGM.getModule().getTargetTriple());
1850-
if (TT.supportsCOMDAT()) {
1851-
VersionVariable->setLinkage(llvm::GlobalValue::ExternalLinkage);
1852-
VersionVariable->setComdat(CGM.getModule().getOrInsertComdat(VarName));
1853-
}
18541834
}
18551835

18561836
unsigned CoverageMappingModuleGen::getFileID(FileEntryRef File) {

clang/test/CodeGen/coverage-profile-raw-version.c

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

compiler-rt/test/profile/Linux/coverage-debug-info-correlate.cpp

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

llvm/include/llvm/ProfileData/Coverage/CoverageMappingReader.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,8 @@ class BinaryCoverageReader : public CoverageMappingReader {
203203
BinaryCoverageReader &operator=(const BinaryCoverageReader &) = delete;
204204

205205
static Expected<std::vector<std::unique_ptr<BinaryCoverageReader>>>
206-
create(MemoryBufferRef ObjectBuffer,
207-
StringRef Arch,
206+
create(MemoryBufferRef ObjectBuffer, StringRef Arch,
208207
SmallVectorImpl<std::unique_ptr<MemoryBuffer>> &ObjectFileBuffers,
209-
InstrProfSymtab& IndexedProfSymTab,
210208
StringRef CompilationDir = "",
211209
SmallVectorImpl<object::BuildIDRef> *BinaryIDs = nullptr);
212210

llvm/include/llvm/ProfileData/InstrProfCorrelator.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ class InstrProfCorrelator {
3939
/// \param MaxWarnings the maximum number of warnings to emit (0 = no limit)
4040
virtual Error correlateProfileData(int MaxWarnings) = 0;
4141

42-
virtual Error correlateCovUnusedFuncNames(int MaxWarnings) = 0;
43-
4442
/// Process debug info and dump the correlation data.
4543
/// \param MaxWarnings the maximum number of warnings to emit (0 = no limit)
4644
virtual Error dumpYaml(int MaxWarnings, raw_ostream &OS) = 0;
@@ -54,12 +52,6 @@ class InstrProfCorrelator {
5452
/// Return the number of bytes in the names string.
5553
size_t getNamesSize() const { return Names.size(); }
5654

57-
const char *getCovUnusedFuncNamesPointer() const {
58-
return CovUnusedFuncNames.c_str();
59-
}
60-
61-
size_t getCovUnusedFuncNamesSize() const { return CovUnusedFuncNames.size(); }
62-
6355
/// Return the size of the counters section in bytes.
6456
uint64_t getCountersSectionSize() const {
6557
return Ctx->CountersSectionEnd - Ctx->CountersSectionStart;
@@ -68,7 +60,6 @@ class InstrProfCorrelator {
6860
static const char *FunctionNameAttributeName;
6961
static const char *CFGHashAttributeName;
7062
static const char *NumCountersAttributeName;
71-
static const char *CovFunctionNameAttributeName;
7263

7364
enum InstrProfCorrelatorKind { CK_32Bit, CK_64Bit };
7465
InstrProfCorrelatorKind getKind() const { return Kind; }
@@ -92,7 +83,6 @@ class InstrProfCorrelator {
9283

9384
std::string Names;
9485
std::vector<std::string> NamesVec;
95-
std::string CovUnusedFuncNames;
9686

9787
struct Probe {
9888
std::string FunctionName;
@@ -215,8 +205,6 @@ class DwarfInstrProfCorrelator : public InstrProfCorrelatorImpl<IntPtrT> {
215205
void correlateProfileDataImpl(
216206
int MaxWarnings,
217207
InstrProfCorrelator::CorrelationData *Data = nullptr) override;
218-
219-
Error correlateCovUnusedFuncNames(int MaxWarnings) override;
220208
};
221209

222210
} // end namespace llvm

llvm/lib/ProfileData/Coverage/CoverageMapping.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -390,12 +390,11 @@ Error CoverageMapping::loadFromFile(
390390
MemoryBufferRef CovMappingBufRef =
391391
CovMappingBufOrErr.get()->getMemBufferRef();
392392
SmallVector<std::unique_ptr<MemoryBuffer>, 4> Buffers;
393-
InstrProfSymtab &ProfSymTab = ProfileReader.getSymtab();
394393

395394
SmallVector<object::BuildIDRef> BinaryIDs;
396395
auto CoverageReadersOrErr = BinaryCoverageReader::create(
397-
CovMappingBufRef, Arch, Buffers, ProfSymTab,
398-
CompilationDir, FoundBinaryIDs ? &BinaryIDs : nullptr);
396+
CovMappingBufRef, Arch, Buffers, CompilationDir,
397+
FoundBinaryIDs ? &BinaryIDs : nullptr);
399398
if (Error E = CoverageReadersOrErr.takeError()) {
400399
E = handleMaybeNoDataFoundError(std::move(E));
401400
if (E)

llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp

Lines changed: 20 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include "llvm/Object/MachOUniversal.h"
2626
#include "llvm/Object/ObjectFile.h"
2727
#include "llvm/ProfileData/InstrProf.h"
28-
#include "llvm/ProfileData/InstrProfReader.h"
2928
#include "llvm/Support/Casting.h"
3029
#include "llvm/Support/Compression.h"
3130
#include "llvm/Support/Debug.h"
@@ -1022,23 +1021,9 @@ static Expected<std::vector<SectionRef>> lookupSections(ObjectFile &OF,
10221021
return Sections;
10231022
}
10241023

1025-
static Error getProfileNamesFromDebugInfo(StringRef FileName,
1026-
InstrProfSymtab &ProfileNames) {
1027-
std::unique_ptr<InstrProfCorrelator> Correlator;
1028-
if (auto E = InstrProfCorrelator::get(FileName).moveInto(Correlator))
1029-
return E;
1030-
if (auto E = Correlator->correlateCovUnusedFuncNames(0))
1031-
return E;
1032-
if (auto E = ProfileNames.create(
1033-
StringRef(Correlator->getCovUnusedFuncNamesPointer(),
1034-
Correlator->getCovUnusedFuncNamesSize())))
1035-
return E;
1036-
return Error::success();
1037-
}
1038-
10391024
static Expected<std::unique_ptr<BinaryCoverageReader>>
10401025
loadBinaryFormat(std::unique_ptr<Binary> Bin, StringRef Arch,
1041-
InstrProfSymtab &ProfSymTab, StringRef CompilationDir = "",
1026+
StringRef CompilationDir = "",
10421027
object::BuildIDRef *BinaryID = nullptr) {
10431028
std::unique_ptr<ObjectFile> OF;
10441029
if (auto *Universal = dyn_cast<MachOUniversalBinary>(Bin.get())) {
@@ -1067,30 +1052,11 @@ loadBinaryFormat(std::unique_ptr<Binary> Bin, StringRef Arch,
10671052

10681053
// Look for the sections that we are interested in.
10691054
auto ObjFormat = OF->getTripleObjectFormat();
1070-
// Without debug info correlation, all function names are stored in the
1071-
// binary's profile name section.
1072-
// When debug info correlation is enabled, instrumented function names are
1073-
// stored in the indexed profile file, and unused function names are stored in
1074-
// the binary's debug info.
1075-
InstrProfSymtab ProfileNames = ProfSymTab;
10761055
auto NamesSection =
10771056
lookupSections(*OF, getInstrProfSectionName(IPSK_name, ObjFormat,
1078-
/*AddSegmentInfo=*/false));
1079-
if (auto E = NamesSection.takeError()) {
1080-
if (OF->hasDebugInfo()) {
1081-
if (auto E =
1082-
getProfileNamesFromDebugInfo(OF->getFileName(), ProfileNames))
1083-
return make_error<CoverageMapError>(coveragemap_error::malformed);
1084-
}
1085-
consumeError(std::move(E));
1086-
} else {
1087-
std::vector<SectionRef> NamesSectionRefs = *NamesSection;
1088-
if (NamesSectionRefs.size() != 1)
1089-
return make_error<CoverageMapError>(coveragemap_error::malformed);
1090-
if (Error E = ProfileNames.create(NamesSectionRefs.back()))
1091-
return std::move(E);
1092-
}
1093-
1057+
/*AddSegmentInfo=*/false));
1058+
if (auto E = NamesSection.takeError())
1059+
return std::move(E);
10941060
auto CoverageSection =
10951061
lookupSections(*OF, getInstrProfSectionName(IPSK_covmap, ObjFormat,
10961062
/*AddSegmentInfo=*/false));
@@ -1105,6 +1071,15 @@ loadBinaryFormat(std::unique_ptr<Binary> Bin, StringRef Arch,
11051071
return CoverageMappingOrErr.takeError();
11061072
StringRef CoverageMapping = CoverageMappingOrErr.get();
11071073

1074+
InstrProfSymtab ProfileNames;
1075+
std::vector<SectionRef> NamesSectionRefs = *NamesSection;
1076+
if (NamesSectionRefs.size() != 1)
1077+
return make_error<CoverageMapError>(
1078+
coveragemap_error::malformed,
1079+
"the size of coverage mapping section is not one");
1080+
if (Error E = ProfileNames.create(NamesSectionRefs.back()))
1081+
return std::move(E);
1082+
11081083
// Look for the coverage records section (Version4 only).
11091084
auto CoverageRecordsSections =
11101085
lookupSections(*OF, getInstrProfSectionName(IPSK_covfun, ObjFormat,
@@ -1176,8 +1151,7 @@ Expected<std::vector<std::unique_ptr<BinaryCoverageReader>>>
11761151
BinaryCoverageReader::create(
11771152
MemoryBufferRef ObjectBuffer, StringRef Arch,
11781153
SmallVectorImpl<std::unique_ptr<MemoryBuffer>> &ObjectFileBuffers,
1179-
InstrProfSymtab &ProfSymTab, StringRef CompilationDir,
1180-
SmallVectorImpl<object::BuildIDRef> *BinaryIDs) {
1154+
StringRef CompilationDir, SmallVectorImpl<object::BuildIDRef> *BinaryIDs) {
11811155
std::vector<std::unique_ptr<BinaryCoverageReader>> Readers;
11821156

11831157
if (ObjectBuffer.getBuffer().size() > sizeof(TestingFormatMagic)) {
@@ -1221,8 +1195,8 @@ BinaryCoverageReader::create(
12211195
}
12221196

12231197
return BinaryCoverageReader::create(
1224-
ArchiveOrErr.get()->getMemoryBufferRef(), Arch,
1225-
ObjectFileBuffers, ProfSymTab, CompilationDir, BinaryIDs);
1198+
ArchiveOrErr.get()->getMemoryBufferRef(), Arch, ObjectFileBuffers,
1199+
CompilationDir, BinaryIDs);
12261200
}
12271201
}
12281202

@@ -1235,8 +1209,8 @@ BinaryCoverageReader::create(
12351209
return ChildBufOrErr.takeError();
12361210

12371211
auto ChildReadersOrErr = BinaryCoverageReader::create(
1238-
ChildBufOrErr.get(), Arch, ObjectFileBuffers, ProfSymTab,
1239-
CompilationDir, BinaryIDs);
1212+
ChildBufOrErr.get(), Arch, ObjectFileBuffers, CompilationDir,
1213+
BinaryIDs);
12401214
if (!ChildReadersOrErr)
12411215
return ChildReadersOrErr.takeError();
12421216
for (auto &Reader : ChildReadersOrErr.get())
@@ -1256,9 +1230,8 @@ BinaryCoverageReader::create(
12561230
}
12571231

12581232
object::BuildIDRef BinaryID;
1259-
auto ReaderOrErr =
1260-
loadBinaryFormat(std::move(Bin), Arch, ProfSymTab, CompilationDir,
1261-
BinaryIDs ? &BinaryID : nullptr);
1233+
auto ReaderOrErr = loadBinaryFormat(std::move(Bin), Arch, CompilationDir,
1234+
BinaryIDs ? &BinaryID : nullptr);
12621235
if (!ReaderOrErr)
12631236
return ReaderOrErr.takeError();
12641237
Readers.push_back(std::move(ReaderOrErr.get()));

0 commit comments

Comments
 (0)