Skip to content

Commit 19304d2

Browse files
author
git apple-llvm automerger
committed
Merge commit '4bb6bbb9bf76' from llvm.org/main into next
2 parents 0b47cf3 + 4bb6bbb commit 19304d2

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

llvm/lib/Transforms/IPO/SampleProfile.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2415,7 +2415,9 @@ void SampleProfileMatcher::runOnFunction(const Function &F) {
24152415
findProfileAnchors(*FSFlattened, ProfileAnchors);
24162416

24172417
// Detect profile mismatch for profile staleness metrics report.
2418-
if (ReportProfileStaleness || PersistProfileStaleness) {
2418+
// Skip reporting the metrics for imported functions.
2419+
if (!GlobalValue::isAvailableExternallyLinkage(F.getLinkage()) &&
2420+
(ReportProfileStaleness || PersistProfileStaleness)) {
24192421
// Use top-level nested FS for counting profile mismatch metrics since
24202422
// currently once a callsite is mismatched, all its children profiles are
24212423
// dropped.

llvm/test/Transforms/SampleProfile/Inputs/pseudo-probe-stale-profile-matching-lto.prof

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ main:6822:0
2323
!CFGChecksum: 1125988587804525
2424
bar:2401:2401
2525
1: 2401
26-
!CFGChecksum: 4294967295
26+
# Orignal CFGChecksum is 4294967295
27+
!CFGChecksum: 123
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
; REQUIRES: x86_64-linux
2+
; 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
3+
; RUN: FileCheck %s --input-file %t
4+
; RUN: FileCheck %s --input-file %t.ll -check-prefix=CHECK-MD
5+
6+
; CHECK: (1/1) of functions' profile are invalid and (6822/6822) of samples are discarded due to function hash mismatch.
7+
; CHECK: (4/4) of callsites' profile are invalid and (5026/5026) of samples are discarded due to callsite location mismatch.
8+
9+
10+
; 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}

0 commit comments

Comments
 (0)