Skip to content

Commit

Permalink
[CSSPGO] Print "context-nested" instead of "preilnined" for ProfileSu…
Browse files Browse the repository at this point in the history
…mmarySection.

Reviewed By: wenlei

Differential Revision: https://reviews.llvm.org/D117141
  • Loading branch information
htyu committed Jan 19, 2022
1 parent 2e2999c commit ff0b634
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
8 changes: 5 additions & 3 deletions llvm/include/llvm/ProfileData/SampleProf.h
Expand Up @@ -195,19 +195,21 @@ enum class SecProfSummaryFlags : uint32_t {
/// The common profile is usually merged from profiles collected
/// from running other targets.
SecFlagPartial = (1 << 0),
/// SecFlagContext means this is context-sensitive profile for
/// SecFlagContext means this is context-sensitive flat profile for
/// CSSPGO
SecFlagFullContext = (1 << 1),
/// SecFlagFSDiscriminator means this profile uses flow-sensitive
/// discriminators.
SecFlagFSDiscriminator = (1 << 2)
SecFlagFSDiscriminator = (1 << 2),
/// SecFlagIsCSNested means this is context-sensitive nested profile for
/// CSSPGO
SecFlagIsCSNested = (1 << 4),
};

enum class SecFuncMetadataFlags : uint32_t {
SecFlagInvalid = 0,
SecFlagIsProbeBased = (1 << 0),
SecFlagHasAttribute = (1 << 1),
SecFlagIsCSNested = (1 << 2),
};

enum class SecFuncOffsetFlags : uint32_t {
Expand Down
9 changes: 4 additions & 5 deletions llvm/lib/ProfileData/SampleProfReader.cpp
Expand Up @@ -655,6 +655,8 @@ std::error_code SampleProfileReaderExtBinaryBase::readOneSection(
Summary->setPartialProfile(true);
if (hasSecFlag(Entry, SecProfSummaryFlags::SecFlagFullContext))
FunctionSamples::ProfileIsCSFlat = ProfileIsCSFlat = true;
if (hasSecFlag(Entry, SecProfSummaryFlags::SecFlagIsCSNested))
FunctionSamples::ProfileIsCSNested = ProfileIsCSNested;
if (hasSecFlag(Entry, SecProfSummaryFlags::SecFlagFSDiscriminator))
FunctionSamples::ProfileIsFS = ProfileIsFS = true;
break;
Expand Down Expand Up @@ -688,9 +690,6 @@ std::error_code SampleProfileReaderExtBinaryBase::readOneSection(
ProfileIsProbeBased =
hasSecFlag(Entry, SecFuncMetadataFlags::SecFlagIsProbeBased);
FunctionSamples::ProfileIsProbeBased = ProfileIsProbeBased;
ProfileIsCSNested =
hasSecFlag(Entry, SecFuncMetadataFlags::SecFlagIsCSNested);
FunctionSamples::ProfileIsCSNested = ProfileIsCSNested;
bool HasAttribute =
hasSecFlag(Entry, SecFuncMetadataFlags::SecFlagHasAttribute);
if (std::error_code EC = readFuncMetadata(HasAttribute))
Expand Down Expand Up @@ -1276,6 +1275,8 @@ static std::string getSecFlagsStr(const SecHdrTableEntry &Entry) {
Flags.append("partial,");
if (hasSecFlag(Entry, SecProfSummaryFlags::SecFlagFullContext))
Flags.append("context,");
if (hasSecFlag(Entry, SecProfSummaryFlags::SecFlagIsCSNested))
Flags.append("context-nested,");
if (hasSecFlag(Entry, SecProfSummaryFlags::SecFlagFSDiscriminator))
Flags.append("fs-discriminator,");
break;
Expand All @@ -1288,8 +1289,6 @@ static std::string getSecFlagsStr(const SecHdrTableEntry &Entry) {
Flags.append("probe,");
if (hasSecFlag(Entry, SecFuncMetadataFlags::SecFlagHasAttribute))
Flags.append("attr,");
if (hasSecFlag(Entry, SecFuncMetadataFlags::SecFlagIsCSNested))
Flags.append("preinlined,");
break;
default:
break;
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/ProfileData/SampleProfWriter.cpp
Expand Up @@ -323,13 +323,13 @@ std::error_code SampleProfileWriterExtBinaryBase::writeOneSection(
setToCompressSection(SecProfileSymbolList);
if (Type == SecFuncMetadata && FunctionSamples::ProfileIsProbeBased)
addSectionFlag(SecFuncMetadata, SecFuncMetadataFlags::SecFlagIsProbeBased);
if (Type == SecFuncMetadata && FunctionSamples::ProfileIsCSNested)
addSectionFlag(SecFuncMetadata, SecFuncMetadataFlags::SecFlagIsCSNested);
if (Type == SecFuncMetadata &&
(FunctionSamples::ProfileIsCSFlat || FunctionSamples::ProfileIsCSNested))
addSectionFlag(SecFuncMetadata, SecFuncMetadataFlags::SecFlagHasAttribute);
if (Type == SecProfSummary && FunctionSamples::ProfileIsCSFlat)
addSectionFlag(SecProfSummary, SecProfSummaryFlags::SecFlagFullContext);
if (Type == SecProfSummary && FunctionSamples::ProfileIsCSNested)
addSectionFlag(SecProfSummary, SecProfSummaryFlags::SecFlagIsCSNested);
if (Type == SecProfSummary && FunctionSamples::ProfileIsFS)
addSectionFlag(SecProfSummary, SecProfSummaryFlags::SecFlagFSDiscriminator);

Expand Down
4 changes: 1 addition & 3 deletions llvm/test/tools/llvm-profdata/cs-sample-nested-profile.test
Expand Up @@ -152,6 +152,4 @@ RUN: FileCheck %s < %t.proftext --match-full-lines --strict-whitespace -check-pr
; PROBE-NEXT: !CFGChecksum: 563022570642068


; PREINLINE: FunctionMetadata {{.*}} Flags: {attr,preinlined}


; PREINLINE: ProfileSummarySection {{.*}} Flags: {context-nested}

0 comments on commit ff0b634

Please sign in to comment.