aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/ProfileData/SampleProfReader.cpp
diff options
context:
space:
mode:
authorWei Mi <wmi@google.com>2020-04-03 11:57:36 -0700
committerWei Mi <wmi@google.com>2020-04-07 14:28:25 -0700
commitb49eac71ad76cd8ee3771745ff591ee8771eab1b (patch)
tree8c340a0893aed56338627d4b52e3428bf72727c6 /llvm/lib/ProfileData/SampleProfReader.cpp
parent96e51ed005a960d1c746a0a7774ce255bb497ed5 (diff)
downloadllvm-b49eac71ad76cd8ee3771745ff591ee8771eab1b.zip
llvm-b49eac71ad76cd8ee3771745ff591ee8771eab1b.tar.gz
llvm-b49eac71ad76cd8ee3771745ff591ee8771eab1b.tar.bz2
Recommit [SampleFDO] Add flag for partial profile.
Fix the error of show-prof-info.test on some platforms without zlib. The common profile usage is to collect profile from a target and then use the profile to guide the optimized build for the same target. There are some cases that no profile can be collected for a target. In those cases, although no full profile is available, it is possible to have some partial profile collected from other targets to optimize common libraries and utilities. A flag is needed to tell the partial profile from the full profile apart, so compiler can use different strategy for them. Differential Revision: https://reviews.llvm.org/D77426
Diffstat (limited to 'llvm/lib/ProfileData/SampleProfReader.cpp')
-rw-r--r--llvm/lib/ProfileData/SampleProfReader.cpp33
1 files changed, 32 insertions, 1 deletions
diff --git a/llvm/lib/ProfileData/SampleProfReader.cpp b/llvm/lib/ProfileData/SampleProfReader.cpp
index 33efb51..e27bf07 100644
--- a/llvm/lib/ProfileData/SampleProfReader.cpp
+++ b/llvm/lib/ProfileData/SampleProfReader.cpp
@@ -478,6 +478,8 @@ std::error_code SampleProfileReaderExtBinary::readOneSection(
case SecProfSummary:
if (std::error_code EC = readSummary())
return EC;
+ if (hasSecFlag(Entry, SecProfSummaryFlags::SecFlagPartial))
+ Summary->setPartialProfile(true);
break;
case SecNameTable:
if (std::error_code EC = readNameTableSec(
@@ -831,11 +833,40 @@ uint64_t SampleProfileReaderExtBinaryBase::getFileSize() {
return FileSize;
}
+static std::string getSecFlagsStr(const SecHdrTableEntry &Entry) {
+ std::string Flags;
+ if (hasSecFlag(Entry, SecCommonFlags::SecFlagCompress))
+ Flags.append("{compressed,");
+ else
+ Flags.append("{");
+
+ switch (Entry.Type) {
+ case SecNameTable:
+ if (hasSecFlag(Entry, SecNameTableFlags::SecFlagMD5Name))
+ Flags.append("md5,");
+ break;
+ case SecProfSummary:
+ if (hasSecFlag(Entry, SecProfSummaryFlags::SecFlagPartial))
+ Flags.append("partial,");
+ break;
+ default:
+ break;
+ }
+ char &last = Flags.back();
+ if (last == ',')
+ last = '}';
+ else
+ Flags.append("}");
+ return Flags;
+}
+
bool SampleProfileReaderExtBinaryBase::dumpSectionInfo(raw_ostream &OS) {
uint64_t TotalSecsSize = 0;
for (auto &Entry : SecHdrTable) {
OS << getSecName(Entry.Type) << " - Offset: " << Entry.Offset
- << ", Size: " << Entry.Size << "\n";
+ << ", Size: " << Entry.Size << ", Flags: " << getSecFlagsStr(Entry)
+ << "\n";
+ ;
TotalSecsSize += getSectionSize(Entry.Type);
}
uint64_t HeaderSize = SecHdrTable.front().Offset;