From f170595249196f1ca5c3a70118fedc1043c093b3 Mon Sep 17 00:00:00 2001 From: Ellis Hoag Date: Tue, 25 Jan 2022 12:29:11 -0800 Subject: [PATCH] [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 --- .../Darwin/instrprof-debug-info-correlate.c | 2 -- .../Linux/instrprof-debug-info-correlate.c | 2 -- .../llvm/ProfileData/InstrProfCorrelator.h | 17 +++++++---------- llvm/lib/ProfileData/InstrProfCorrelator.cpp | 8 ++++---- llvm/lib/ProfileData/InstrProfReader.cpp | 4 ++-- 5 files changed, 13 insertions(+), 20 deletions(-) diff --git a/compiler-rt/test/profile/Darwin/instrprof-debug-info-correlate.c b/compiler-rt/test/profile/Darwin/instrprof-debug-info-correlate.c index 837e1f428d1e..f628f928576a 100644 --- a/compiler-rt/test/profile/Darwin/instrprof-debug-info-correlate.c +++ b/compiler-rt/test/profile/Darwin/instrprof-debug-info-correlate.c @@ -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 diff --git a/compiler-rt/test/profile/Linux/instrprof-debug-info-correlate.c b/compiler-rt/test/profile/Linux/instrprof-debug-info-correlate.c index 4f46586a1699..c5f2a65c000d 100644 --- a/compiler-rt/test/profile/Linux/instrprof-debug-info-correlate.c +++ b/compiler-rt/test/profile/Linux/instrprof-debug-info-correlate.c @@ -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 diff --git a/llvm/include/llvm/ProfileData/InstrProfCorrelator.h b/llvm/include/llvm/ProfileData/InstrProfCorrelator.h index 81ecbc2813ab..e254169c447a 100644 --- a/llvm/include/llvm/ProfileData/InstrProfCorrelator.h +++ b/llvm/include/llvm/ProfileData/InstrProfCorrelator.h @@ -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>> get(std::unique_ptr Ctx, @@ -98,7 +95,7 @@ public: protected: std::vector> 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 Ctx) : InstrProfCorrelator(Kind, std::move(Ctx)){}; - std::vector Names; + std::vector NamesVec; llvm::DenseSet 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: diff --git a/llvm/lib/ProfileData/InstrProfCorrelator.cpp b/llvm/lib/ProfileData/InstrProfCorrelator.cpp index 5f06541916dd..4bd9a3df950d 100644 --- a/llvm/lib/ProfileData/InstrProfCorrelator.cpp +++ b/llvm/lib/ProfileData/InstrProfCorrelator.cpp @@ -125,12 +125,12 @@ InstrProfCorrelatorImpl::get( template Error InstrProfCorrelatorImpl::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::addProbe(StringRef FunctionName, maybeSwap(NumCounters), /*NumValueSites=*/{maybeSwap(0), maybeSwap(0)}, }); - Names.push_back(FunctionName.str()); + NamesVec.push_back(FunctionName.str()); } template diff --git a/llvm/lib/ProfileData/InstrProfReader.cpp b/llvm/lib/ProfileData/InstrProfReader.cpp index 2544e5bcf647..861ff61df510 100644 --- a/llvm/lib/ProfileData/InstrProfReader.cpp +++ b/llvm/lib/ProfileData/InstrProfReader.cpp @@ -411,8 +411,8 @@ Error RawInstrProfReader::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 *>( Start + DataOffset);