[llvm] c560585 - [CSSPGO] Skip dangling probe value when computing profile summary

Wenlei He via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 1 22:55:55 PDT 2021


Author: Wenlei He
Date: 2021-04-01T22:49:11-07:00
New Revision: c5605857bb77a6f2f08304dcc5e35e0637851ffe

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

LOG: [CSSPGO] Skip dangling probe value when computing profile summary

Recently we switched to use InvalidProbeCount = UINT64_MAX (instead of 0) to represent dangling probe, but UINT64_MAX is not excluded when computing profile summary. This caused profile summary to produce incorrect hot/cold threshold. The change fixed it by excluding UINT64_MAX from summary builder.

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

Added: 
    

Modified: 
    llvm/lib/ProfileData/ProfileSummaryBuilder.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/ProfileData/ProfileSummaryBuilder.cpp b/llvm/lib/ProfileData/ProfileSummaryBuilder.cpp
index 0e03aa50173da..b6b4e79d5d22e 100644
--- a/llvm/lib/ProfileData/ProfileSummaryBuilder.cpp
+++ b/llvm/lib/ProfileData/ProfileSummaryBuilder.cpp
@@ -68,8 +68,12 @@ void SampleProfileSummaryBuilder::addRecord(
     if (FS.getHeadSamples() > MaxFunctionCount)
       MaxFunctionCount = FS.getHeadSamples();
   }
-  for (const auto &I : FS.getBodySamples())
-    addCount(I.second.getSamples());
+  for (const auto &I : FS.getBodySamples()) {
+    uint64_t Count = I.second.getSamples();
+    if (!sampleprof::FunctionSamples::ProfileIsProbeBased ||
+        (Count != sampleprof::FunctionSamples::InvalidProbeCount))
+      addCount(Count);
+  }
   for (const auto &I : FS.getCallsiteSamples())
     for (const auto &CS : I.second)
       addRecord(CS.second, true);


        


More information about the llvm-commits mailing list