Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SamplePGO] Handle FS discriminators in SampleProfileMatcher #90858

Merged
merged 1 commit into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions llvm/lib/Transforms/IPO/SampleProfileMatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ void SampleProfileMatcher::findIRAnchors(
DIL = DIL->getInlinedAt();
} while (DIL->getInlinedAt());

LineLocation Callsite = FunctionSamples::getCallSiteIdentifier(DIL);
LineLocation Callsite = FunctionSamples::getCallSiteIdentifier(
DIL, FunctionSamples::ProfileIsFS);
StringRef CalleeName = PrevDIL->getSubprogramLinkageName();
return std::make_pair(Callsite, CalleeName);
};
Expand Down Expand Up @@ -82,7 +83,8 @@ void SampleProfileMatcher::findIRAnchors(
if (DIL->getInlinedAt()) {
IRAnchors.emplace(FindTopLevelInlinedCallsite(DIL));
} else {
LineLocation Callsite = FunctionSamples::getCallSiteIdentifier(DIL);
LineLocation Callsite = FunctionSamples::getCallSiteIdentifier(
DIL, FunctionSamples::ProfileIsFS);
StringRef CalleeName = GetCanonicalCalleeName(dyn_cast<CallBase>(&I));
IRAnchors.emplace(Callsite, CalleeName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ main:9229397:0
7: 0
2: foo:1479916
1: 47663
1.1: 46683 bar:43238
1.15: 46683 bar:43238
2: 4519 bar:4932
3: 48723
4: foo:1505537
1: 48604
1.1: 46965 bar:44479
1.15: 46965 bar:44479
2: 4613 bar:4967
3: 49087
bar:2333388:196222
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
; REQUIRES: x86_64-linux
; REQUIRES: asserts
; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/non-probe-stale-profile-matching.prof --salvage-stale-profile -S --debug-only=sample-profile,sample-profile-matcher,sample-profile-impl 2>&1 | FileCheck %s
; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/non-probe-stale-profile-matching.prof --salvage-stale-profile -S --debug-only=sample-profile,sample-profile-matcher,sample-profile-impl -profile-isfs 2>&1 | FileCheck %s

; The profiled source code:

Expand Down Expand Up @@ -51,7 +51,7 @@
; CHECK: Run stale profile matching for bar

; CHECK: Run stale profile matching for foo
; CHECK: Callsite with callee:bar is matched from 1.1 to 1.1
; CHECK: Callsite with callee:bar is matched from 1.15 to 1.15
; CHECK: Callsite with callee:bar is matched from 2 to 2

; CHECK: Run stale profile matching for main
Expand Down Expand Up @@ -183,7 +183,7 @@ attributes #3 = { mustprogress nocallback nofree nosync nounwind willreturn memo
!15 = !DILocation(line: 7, column: 9, scope: !14)
!16 = !DILocation(line: 7, column: 7, scope: !14)
!17 = !DILocation(line: 7, column: 23, scope: !18)
!18 = !DILexicalBlockFile(scope: !14, file: !10, discriminator: 2)
!18 = !DILexicalBlockFile(scope: !14, file: !10, discriminator: 15)
!19 = !DILocation(line: 7, column: 15, scope: !18)
!20 = !DILocation(line: 8, column: 21, scope: !14)
!21 = !DILocation(line: 8, column: 15, scope: !14)
Expand All @@ -201,7 +201,7 @@ attributes #3 = { mustprogress nocallback nofree nosync nounwind willreturn memo
!33 = !DILocation(line: 14, column: 8, scope: !25)
!34 = !DILocation(line: 14, scope: !25)
!35 = !DILocation(line: 14, column: 21, scope: !36)
!36 = !DILexicalBlockFile(scope: !25, file: !10, discriminator: 2)
!36 = !DILexicalBlockFile(scope: !25, file: !10, discriminator: 15)
!37 = !DILocation(line: 14, column: 3, scope: !36)
!38 = !DILocation(line: 14, column: 3, scope: !39)
!39 = !DILexicalBlockFile(scope: !25, file: !10, discriminator: 4)
Expand Down
Loading