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

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


wenlei created this revision.
wenlei added reviewers: hoy, wmi, wlei.
Herald added subscribers: modimo, lxfind, hiraditya, eraman.
wenlei requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99788

Files:
  llvm/lib/ProfileData/ProfileSummaryBuilder.cpp


Index: llvm/lib/ProfileData/ProfileSummaryBuilder.cpp
===================================================================
--- llvm/lib/ProfileData/ProfileSummaryBuilder.cpp
+++ llvm/lib/ProfileData/ProfileSummaryBuilder.cpp
@@ -68,8 +68,12 @@
     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);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D99788.334896.patch
Type: text/x-patch
Size: 799 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210402/038b4940/attachment.bin>


More information about the llvm-commits mailing list