[InstrProf][Correlator] Do not compress names when reading debug info

There is no need to compress the names string when correlating with
debug info since InstrProfReader will immediately uncompress it anyway.
This also removes the dependency on zlib in this case.

Reviewed By: kyulee

Differential Revision: https://reviews.llvm.org/D118176
This commit is contained in:
Ellis Hoag 2022-01-25 12:29:11 -08:00
parent 6427f4c52c
commit f170595249
5 changed files with 13 additions and 20 deletions

View File

@ -1,5 +1,3 @@
// REQUIRES: zlib
// Value profiling is currently not supported in lightweight mode.
// RUN: %clang_pgogen -o %t -g -mllvm --debug-info-correlate -mllvm --disable-vp=true %S/../Inputs/instrprof-debug-info-correlate-main.cpp %S/../Inputs/instrprof-debug-info-correlate-foo.cpp
// RUN: env LLVM_PROFILE_FILE=%t.proflite %run %t

View File

@ -1,5 +1,3 @@
// REQUIRES: zlib
// Value profiling is currently not supported in lightweight mode.
// RUN: %clang_pgogen -o %t.normal -mllvm --disable-vp=true %S/../Inputs/instrprof-debug-info-correlate-main.cpp %S/../Inputs/instrprof-debug-info-correlate-foo.cpp
// RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t.normal

View File

@ -83,14 +83,11 @@ public:
/// Return the number of ProfileData elements.
size_t getDataSize() const { return Data.size(); }
/// Return a pointer to the compressed names string that this class
/// constructs.
const char *getCompressedNamesPointer() const {
return CompressedNames.c_str();
}
/// Return a pointer to the names string that this class constructs.
const char *getNamesPointer() const { return Names.c_str(); }
/// Return the number of bytes in the compressed names string.
size_t getCompressedNamesSize() const { return CompressedNames.size(); }
/// Return the number of bytes in the names string.
size_t getNamesSize() const { return Names.size(); }
static llvm::Expected<std::unique_ptr<InstrProfCorrelatorImpl<IntPtrT>>>
get(std::unique_ptr<InstrProfCorrelator::Context> Ctx,
@ -98,7 +95,7 @@ public:
protected:
std::vector<RawInstrProf::ProfileData<IntPtrT>> Data;
std::string CompressedNames;
std::string Names;
Error correlateProfileData() override;
virtual void correlateProfileDataImpl() = 0;
@ -110,7 +107,7 @@ private:
InstrProfCorrelatorImpl(InstrProfCorrelatorKind Kind,
std::unique_ptr<InstrProfCorrelator::Context> Ctx)
: InstrProfCorrelator(Kind, std::move(Ctx)){};
std::vector<std::string> Names;
std::vector<std::string> NamesVec;
llvm::DenseSet<IntPtrT> CounterOffsets;
// Byte-swap the value if necessary.
@ -140,7 +137,7 @@ private:
static bool isDIEOfProbe(const DWARFDie &Die);
/// Iterate over DWARF DIEs to find those that symbolize instrumentation
/// probes and construct the ProfileData vector and CompressedNames string.
/// probes and construct the ProfileData vector and Names string.
///
/// Here is some example DWARF for an instrumentation probe we are looking
/// for:

View File

@ -125,12 +125,12 @@ InstrProfCorrelatorImpl<IntPtrT>::get(
template <class IntPtrT>
Error InstrProfCorrelatorImpl<IntPtrT>::correlateProfileData() {
assert(Data.empty() && CompressedNames.empty() && Names.empty());
assert(Data.empty() && Names.empty() && NamesVec.empty());
correlateProfileDataImpl();
auto Result =
collectPGOFuncNameStrings(Names, /*doCompression=*/true, CompressedNames);
collectPGOFuncNameStrings(NamesVec, /*doCompression=*/false, Names);
CounterOffsets.clear();
Names.clear();
NamesVec.clear();
return Result;
}
@ -155,7 +155,7 @@ void InstrProfCorrelatorImpl<IntPtrT>::addProbe(StringRef FunctionName,
maybeSwap<uint32_t>(NumCounters),
/*NumValueSites=*/{maybeSwap<uint16_t>(0), maybeSwap<uint16_t>(0)},
});
Names.push_back(FunctionName.str());
NamesVec.push_back(FunctionName.str());
}
template <class IntPtrT>

View File

@ -411,8 +411,8 @@ Error RawInstrProfReader<IntPtrT>::readHeader(
assert(CountersDelta == 0 && NamesDelta == 0);
Data = Correlator->getDataPointer();
DataEnd = Data + Correlator->getDataSize();
NamesStart = Correlator->getCompressedNamesPointer();
NamesEnd = NamesStart + Correlator->getCompressedNamesSize();
NamesStart = Correlator->getNamesPointer();
NamesEnd = NamesStart + Correlator->getNamesSize();
} else {
Data = reinterpret_cast<const RawInstrProf::ProfileData<IntPtrT> *>(
Start + DataOffset);