Skip to content

Commit 172a054

Browse files
wlei-llvmIcohedron
authored andcommitted
[CSSPGO] Turn on call-graph matching by default for CSSPGO (llvm#125938)
Tested call-graph matching on some of Meta's large services, it works to reuse some renamed function profiles, no negative perf or significant build speed regression observed. Turned it on by default for CSSPGO mode.
1 parent ea6cc73 commit 172a054

5 files changed

+10
-8
lines changed

llvm/lib/Transforms/IPO/SampleProfile.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -2045,9 +2045,11 @@ bool SampleProfileLoader::doInitialization(Module &M,
20452045
// which is currently only available for pseudo-probe mode. Removing the
20462046
// checksum check could cause regressions for some cases, so further tuning
20472047
// might be needed if we want to enable it for all cases.
2048-
if (Reader->profileIsProbeBased() &&
2049-
!SalvageStaleProfile.getNumOccurrences()) {
2050-
SalvageStaleProfile = true;
2048+
if (Reader->profileIsProbeBased()) {
2049+
if (!SalvageStaleProfile.getNumOccurrences())
2050+
SalvageStaleProfile = true;
2051+
if (!SalvageUnusedProfile.getNumOccurrences())
2052+
SalvageUnusedProfile = true;
20512053
}
20522054

20532055
if (!Reader->profileIsCS()) {

llvm/lib/Transforms/IPO/SampleProfileMatcher.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ static cl::opt<unsigned> MinCallCountForCGMatching(
3838
"run stale profile call graph matching."));
3939

4040
static cl::opt<bool> LoadFuncProfileforCGMatching(
41-
"load-func-profile-for-cg-matching", cl::Hidden, cl::init(false),
41+
"load-func-profile-for-cg-matching", cl::Hidden, cl::init(true),
4242
cl::desc(
4343
"Load top-level profiles that the sample reader initially skipped for "
4444
"the call-graph matching (only meaningful for extended binary "

llvm/test/Transforms/SampleProfile/pseudo-probe-callee-profile-mismatch.ll

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
; REQUIRES: x86_64-linux
22
; REQUIRES: asserts
3-
; RUN: opt < %s -passes='thinlto<O2>' -pgo-kind=pgo-sample-use-pipeline -sample-profile-file=%S/Inputs/pseudo-probe-callee-profile-mismatch.prof --salvage-stale-profile -S --debug-only=sample-profile,sample-profile-matcher,sample-profile-impl -pass-remarks=inline 2>&1 | FileCheck %s
3+
; RUN: opt < %s -passes='thinlto<O2>' -pgo-kind=pgo-sample-use-pipeline -sample-profile-file=%S/Inputs/pseudo-probe-callee-profile-mismatch.prof --salvage-stale-profile --salvage-unused-profile=false -S --debug-only=sample-profile,sample-profile-matcher,sample-profile-impl -pass-remarks=inline 2>&1 | FileCheck %s
44

55
; There is no profile-checksum-mismatch attr, even the checksum is mismatched in the pseudo_probe_desc, it doesn't run the matching.
66
; CHECK-NOT: Run stale profile matching for main

llvm/test/Transforms/SampleProfile/pseudo-probe-profile-mismatch-thinlto.ll

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
; 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
2+
; RUN: opt < %S/pseudo-probe-stale-profile-matching-lto.ll -passes='thinlto<O2>' -pgo-kind=pgo-sample-use-pipeline --salvage-unused-profile=false -sample-profile-file=%S/Inputs/pseudo-probe-stale-profile-matching-lto.prof -report-profile-staleness -persist-profile-staleness -S 2>%t -o %t.ll
33
; RUN: FileCheck %s --input-file %t
44
; RUN: FileCheck %s --input-file %t.ll -check-prefix=CHECK-MD
55

llvm/test/Transforms/SampleProfile/pseudo-probe-profile-mismatch.ll

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
; REQUIRES: x86_64-linux
2-
; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/pseudo-probe-profile-mismatch.prof -report-profile-staleness -persist-profile-staleness -S 2>%t -o %t.ll
2+
; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/pseudo-probe-profile-mismatch.prof --salvage-unused-profile=false -report-profile-staleness -persist-profile-staleness -S 2>%t -o %t.ll
33
; RUN: FileCheck %s --input-file %t
44
; RUN: FileCheck %s --input-file %t.ll -check-prefix=CHECK-MD
55
; RUN: llc < %t.ll -filetype=obj -o %t.obj
66
; RUN: llvm-objdump --section-headers %t.obj | FileCheck %s --check-prefix=CHECK-OBJ
77
; RUN: llc < %t.ll -filetype=asm -o - | FileCheck %s --check-prefix=CHECK-ASM
88

9-
; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/pseudo-probe-profile-mismatch-nested.prof -report-profile-staleness -persist-profile-staleness -S 2>&1 | FileCheck %s --check-prefix=CHECK-NESTED
9+
; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/pseudo-probe-profile-mismatch-nested.prof --salvage-unused-profile=false -report-profile-staleness -persist-profile-staleness -S 2>&1 | FileCheck %s --check-prefix=CHECK-NESTED
1010

1111

1212
; CHECK: (2/3) of functions' profile are invalid and (40/50) of samples are discarded due to function hash mismatch.

0 commit comments

Comments
 (0)