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

Hongtao Yu via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 18 18:10:49 PST 2022


Author: Hongtao Yu
Date: 2022-01-18T18:10:42-08:00
New Revision: ff0b634d97b9dbcd3d245ce60cf763d2c304c80c

URL: https://github.com/llvm/llvm-project/commit/ff0b634d97b9dbcd3d245ce60cf763d2c304c80c
DIFF: https://github.com/llvm/llvm-project/commit/ff0b634d97b9dbcd3d245ce60cf763d2c304c80c.diff

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

Reviewed By: wenlei

Differential Revision: https://reviews.llvm.org/D117141

Added: 
    

Modified: 
    llvm/include/llvm/ProfileData/SampleProf.h
    llvm/lib/ProfileData/SampleProfReader.cpp
    llvm/lib/ProfileData/SampleProfWriter.cpp
    llvm/test/tools/llvm-profdata/cs-sample-nested-profile.test

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/ProfileData/SampleProf.h b/llvm/include/llvm/ProfileData/SampleProf.h
index dc6522f4ec4ce..6be54d8d78b2f 100644
--- a/llvm/include/llvm/ProfileData/SampleProf.h
+++ b/llvm/include/llvm/ProfileData/SampleProf.h
@@ -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 {

diff  --git a/llvm/lib/ProfileData/SampleProfReader.cpp b/llvm/lib/ProfileData/SampleProfReader.cpp
index da16309fb82cd..80c02faaba043 100644
--- a/llvm/lib/ProfileData/SampleProfReader.cpp
+++ b/llvm/lib/ProfileData/SampleProfReader.cpp
@@ -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;
@@ -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))
@@ -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;
@@ -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;

diff  --git a/llvm/lib/ProfileData/SampleProfWriter.cpp b/llvm/lib/ProfileData/SampleProfWriter.cpp
index 6f02bd203a9fe..b575425d4e94e 100644
--- a/llvm/lib/ProfileData/SampleProfWriter.cpp
+++ b/llvm/lib/ProfileData/SampleProfWriter.cpp
@@ -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);
 

diff  --git a/llvm/test/tools/llvm-profdata/cs-sample-nested-profile.test b/llvm/test/tools/llvm-profdata/cs-sample-nested-profile.test
index 10354bfe9843f..fe28f57676b03 100644
--- a/llvm/test/tools/llvm-profdata/cs-sample-nested-profile.test
+++ b/llvm/test/tools/llvm-profdata/cs-sample-nested-profile.test
@@ -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}


        


More information about the llvm-commits mailing list