[PATCH] D156725: [CSSPGO] Improve profile staleness report for post-link time

Lei Wang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 25 15:09:50 PDT 2023


wlei updated this revision to Diff 553644.
wlei added a comment.

rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156725/new/

https://reviews.llvm.org/D156725

Files:
  llvm/lib/Transforms/IPO/SampleProfile.cpp
  llvm/test/Transforms/SampleProfile/Inputs/pseudo-probe-stale-profile-matching-lto.prof
  llvm/test/Transforms/SampleProfile/pseudo-probe-profile-mismatch-thinlto.ll


Index: llvm/test/Transforms/SampleProfile/pseudo-probe-profile-mismatch-thinlto.ll
===================================================================
--- /dev/null
+++ llvm/test/Transforms/SampleProfile/pseudo-probe-profile-mismatch-thinlto.ll
@@ -0,0 +1,10 @@
+; REQUIRES: x86_64-linux
+; RUN: opt < %S/pseudo-probe-stale-profile-matching-lto.ll -passes='thinlto<O2>' -pgo-kind=pgo-sample-use-pipeline -sample-profile-file=%S/Inputs/pseudo-probe-stale-profile-matching-lto.prof -report-profile-staleness -persist-profile-staleness  -S 2>%t -o %t.ll
+; RUN: FileCheck %s --input-file %t
+; RUN: FileCheck %s --input-file %t.ll -check-prefix=CHECK-MD
+
+; CHECK: (1/1) of functions' profile are invalid and  (6822/6822) of samples are discarded due to function hash mismatch.
+; CHECK: (4/4) of callsites' profile are invalid and (5026/5026) of samples are discarded due to callsite location mismatch.
+
+
+; CHECK-MD: ![[#]] = !{!"NumMismatchedFuncHash", i64 1, !"TotalProfiledFunc", i64 1, !"MismatchedFuncHashSamples", i64 6822, !"TotalFuncHashSamples", i64 6822, !"NumMismatchedCallsites", i64 4, !"TotalProfiledCallsites", i64 4, !"MismatchedCallsiteSamples", i64 5026, !"TotalCallsiteSamples", i64 5026}
Index: llvm/test/Transforms/SampleProfile/Inputs/pseudo-probe-stale-profile-matching-lto.prof
===================================================================
--- llvm/test/Transforms/SampleProfile/Inputs/pseudo-probe-stale-profile-matching-lto.prof
+++ llvm/test/Transforms/SampleProfile/Inputs/pseudo-probe-stale-profile-matching-lto.prof
@@ -23,4 +23,5 @@
  !CFGChecksum: 1125988587804525
 bar:2401:2401
  1: 2401
- !CFGChecksum: 4294967295
+# Orignal CFGChecksum is 4294967295
+ !CFGChecksum: 123
Index: llvm/lib/Transforms/IPO/SampleProfile.cpp
===================================================================
--- llvm/lib/Transforms/IPO/SampleProfile.cpp
+++ llvm/lib/Transforms/IPO/SampleProfile.cpp
@@ -2416,7 +2416,9 @@
   findProfileAnchors(*FSFlattened, ProfileAnchors);
 
   // Detect profile mismatch for profile staleness metrics report.
-  if (FS && (ReportProfileStaleness || PersistProfileStaleness)) {
+  // Skip reporting the metrics for imported functions.
+  if (FS && !GlobalValue::isAvailableExternallyLinkage(F.getLinkage()) &&
+      (ReportProfileStaleness || PersistProfileStaleness)) {
     countProfileMismatches(F, *FS, IRAnchors, ProfileAnchors);
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156725.553644.patch
Type: text/x-patch
Size: 2401 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230825/006f4a6f/attachment.bin>


More information about the llvm-commits mailing list