[llvm] 62ef77c - [CSSPGO] Do not merge a context that is already duplicated into the base profile.

Hongtao Yu via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 14 18:07:19 PST 2022


Author: Hongtao Yu
Date: 2022-02-14T18:07:11-08:00
New Revision: 62ef77ca63c1541e707a2ec5965f08c8320b6876

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

LOG: [CSSPGO] Do not merge a context that is already duplicated into the base profile.

Do not merge a context that is already duplicated into the base profile.

Also fixing a typo caused by previous refactoring.

Reviewed By: wenlei

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

Added: 
    

Modified: 
    llvm/lib/ProfileData/SampleProfReader.cpp
    llvm/lib/Transforms/IPO/SampleProfile.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/ProfileData/SampleProfReader.cpp b/llvm/lib/ProfileData/SampleProfReader.cpp
index 80c02faaba043..5ccf734ef4d8d 100644
--- a/llvm/lib/ProfileData/SampleProfReader.cpp
+++ b/llvm/lib/ProfileData/SampleProfReader.cpp
@@ -656,7 +656,7 @@ std::error_code SampleProfileReaderExtBinaryBase::readOneSection(
     if (hasSecFlag(Entry, SecProfSummaryFlags::SecFlagFullContext))
       FunctionSamples::ProfileIsCSFlat = ProfileIsCSFlat = true;
     if (hasSecFlag(Entry, SecProfSummaryFlags::SecFlagIsCSNested))
-      FunctionSamples::ProfileIsCSNested = ProfileIsCSNested;
+      FunctionSamples::ProfileIsCSNested = ProfileIsCSNested = true;
     if (hasSecFlag(Entry, SecProfSummaryFlags::SecFlagFSDiscriminator))
       FunctionSamples::ProfileIsFS = ProfileIsFS = true;
     break;

diff  --git a/llvm/lib/Transforms/IPO/SampleProfile.cpp b/llvm/lib/Transforms/IPO/SampleProfile.cpp
index 38bbd506381b4..fc0b6f5991a1f 100644
--- a/llvm/lib/Transforms/IPO/SampleProfile.cpp
+++ b/llvm/lib/Transforms/IPO/SampleProfile.cpp
@@ -1542,6 +1542,10 @@ void SampleProfileLoader::promoteMergeNotInlinedContextSamples(
       continue;
     }
 
+    // Do not merge a context that is already duplicated into the base profile.
+    if (FS->getContext().hasAttribute(sampleprof::ContextDuplicatedIntoBase))
+      continue;
+
     if (ProfileMergeInlinee) {
       // A function call can be replicated by optimizations like callsite
       // splitting or jump threading and the replicates end up sharing the


        


More information about the llvm-commits mailing list