[CSSPGO] Print "context-nested" instead of "preilnined" for ProfileSummarySection.

Reviewed By: wenlei

Differential Revision: https://reviews.llvm.org/D117141
This commit is contained in:
Hongtao Yu 2022-01-12 12:21:54 -08:00
parent 2e2999cd44
commit ff0b634d97
4 changed files with 12 additions and 13 deletions

View File

@ -195,19 +195,21 @@ enum class SecProfSummaryFlags : uint32_t {
/// The common profile is usually merged from profiles collected /// The common profile is usually merged from profiles collected
/// from running other targets. /// from running other targets.
SecFlagPartial = (1 << 0), SecFlagPartial = (1 << 0),
/// SecFlagContext means this is context-sensitive profile for /// SecFlagContext means this is context-sensitive flat profile for
/// CSSPGO /// CSSPGO
SecFlagFullContext = (1 << 1), SecFlagFullContext = (1 << 1),
/// SecFlagFSDiscriminator means this profile uses flow-sensitive /// SecFlagFSDiscriminator means this profile uses flow-sensitive
/// discriminators. /// 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 { enum class SecFuncMetadataFlags : uint32_t {
SecFlagInvalid = 0, SecFlagInvalid = 0,
SecFlagIsProbeBased = (1 << 0), SecFlagIsProbeBased = (1 << 0),
SecFlagHasAttribute = (1 << 1), SecFlagHasAttribute = (1 << 1),
SecFlagIsCSNested = (1 << 2),
}; };
enum class SecFuncOffsetFlags : uint32_t { enum class SecFuncOffsetFlags : uint32_t {

View File

@ -655,6 +655,8 @@ std::error_code SampleProfileReaderExtBinaryBase::readOneSection(
Summary->setPartialProfile(true); Summary->setPartialProfile(true);
if (hasSecFlag(Entry, SecProfSummaryFlags::SecFlagFullContext)) if (hasSecFlag(Entry, SecProfSummaryFlags::SecFlagFullContext))
FunctionSamples::ProfileIsCSFlat = ProfileIsCSFlat = true; FunctionSamples::ProfileIsCSFlat = ProfileIsCSFlat = true;
if (hasSecFlag(Entry, SecProfSummaryFlags::SecFlagIsCSNested))
FunctionSamples::ProfileIsCSNested = ProfileIsCSNested;
if (hasSecFlag(Entry, SecProfSummaryFlags::SecFlagFSDiscriminator)) if (hasSecFlag(Entry, SecProfSummaryFlags::SecFlagFSDiscriminator))
FunctionSamples::ProfileIsFS = ProfileIsFS = true; FunctionSamples::ProfileIsFS = ProfileIsFS = true;
break; break;
@ -688,9 +690,6 @@ std::error_code SampleProfileReaderExtBinaryBase::readOneSection(
ProfileIsProbeBased = ProfileIsProbeBased =
hasSecFlag(Entry, SecFuncMetadataFlags::SecFlagIsProbeBased); hasSecFlag(Entry, SecFuncMetadataFlags::SecFlagIsProbeBased);
FunctionSamples::ProfileIsProbeBased = ProfileIsProbeBased; FunctionSamples::ProfileIsProbeBased = ProfileIsProbeBased;
ProfileIsCSNested =
hasSecFlag(Entry, SecFuncMetadataFlags::SecFlagIsCSNested);
FunctionSamples::ProfileIsCSNested = ProfileIsCSNested;
bool HasAttribute = bool HasAttribute =
hasSecFlag(Entry, SecFuncMetadataFlags::SecFlagHasAttribute); hasSecFlag(Entry, SecFuncMetadataFlags::SecFlagHasAttribute);
if (std::error_code EC = readFuncMetadata(HasAttribute)) if (std::error_code EC = readFuncMetadata(HasAttribute))
@ -1276,6 +1275,8 @@ static std::string getSecFlagsStr(const SecHdrTableEntry &Entry) {
Flags.append("partial,"); Flags.append("partial,");
if (hasSecFlag(Entry, SecProfSummaryFlags::SecFlagFullContext)) if (hasSecFlag(Entry, SecProfSummaryFlags::SecFlagFullContext))
Flags.append("context,"); Flags.append("context,");
if (hasSecFlag(Entry, SecProfSummaryFlags::SecFlagIsCSNested))
Flags.append("context-nested,");
if (hasSecFlag(Entry, SecProfSummaryFlags::SecFlagFSDiscriminator)) if (hasSecFlag(Entry, SecProfSummaryFlags::SecFlagFSDiscriminator))
Flags.append("fs-discriminator,"); Flags.append("fs-discriminator,");
break; break;
@ -1288,8 +1289,6 @@ static std::string getSecFlagsStr(const SecHdrTableEntry &Entry) {
Flags.append("probe,"); Flags.append("probe,");
if (hasSecFlag(Entry, SecFuncMetadataFlags::SecFlagHasAttribute)) if (hasSecFlag(Entry, SecFuncMetadataFlags::SecFlagHasAttribute))
Flags.append("attr,"); Flags.append("attr,");
if (hasSecFlag(Entry, SecFuncMetadataFlags::SecFlagIsCSNested))
Flags.append("preinlined,");
break; break;
default: default:
break; break;

View File

@ -323,13 +323,13 @@ std::error_code SampleProfileWriterExtBinaryBase::writeOneSection(
setToCompressSection(SecProfileSymbolList); setToCompressSection(SecProfileSymbolList);
if (Type == SecFuncMetadata && FunctionSamples::ProfileIsProbeBased) if (Type == SecFuncMetadata && FunctionSamples::ProfileIsProbeBased)
addSectionFlag(SecFuncMetadata, SecFuncMetadataFlags::SecFlagIsProbeBased); addSectionFlag(SecFuncMetadata, SecFuncMetadataFlags::SecFlagIsProbeBased);
if (Type == SecFuncMetadata && FunctionSamples::ProfileIsCSNested)
addSectionFlag(SecFuncMetadata, SecFuncMetadataFlags::SecFlagIsCSNested);
if (Type == SecFuncMetadata && if (Type == SecFuncMetadata &&
(FunctionSamples::ProfileIsCSFlat || FunctionSamples::ProfileIsCSNested)) (FunctionSamples::ProfileIsCSFlat || FunctionSamples::ProfileIsCSNested))
addSectionFlag(SecFuncMetadata, SecFuncMetadataFlags::SecFlagHasAttribute); addSectionFlag(SecFuncMetadata, SecFuncMetadataFlags::SecFlagHasAttribute);
if (Type == SecProfSummary && FunctionSamples::ProfileIsCSFlat) if (Type == SecProfSummary && FunctionSamples::ProfileIsCSFlat)
addSectionFlag(SecProfSummary, SecProfSummaryFlags::SecFlagFullContext); addSectionFlag(SecProfSummary, SecProfSummaryFlags::SecFlagFullContext);
if (Type == SecProfSummary && FunctionSamples::ProfileIsCSNested)
addSectionFlag(SecProfSummary, SecProfSummaryFlags::SecFlagIsCSNested);
if (Type == SecProfSummary && FunctionSamples::ProfileIsFS) if (Type == SecProfSummary && FunctionSamples::ProfileIsFS)
addSectionFlag(SecProfSummary, SecProfSummaryFlags::SecFlagFSDiscriminator); addSectionFlag(SecProfSummary, SecProfSummaryFlags::SecFlagFSDiscriminator);

View File

@ -152,6 +152,4 @@ RUN: FileCheck %s < %t.proftext --match-full-lines --strict-whitespace -check-pr
; PROBE-NEXT: !CFGChecksum: 563022570642068 ; PROBE-NEXT: !CFGChecksum: 563022570642068
; PREINLINE: FunctionMetadata {{.*}} Flags: {attr,preinlined} ; PREINLINE: ProfileSummarySection {{.*}} Flags: {context-nested}