Skip to content

Commit 3f4a351

Browse files
wlei-llvmchencha3
authored andcommitted
[CSSPGO] Fix the issue of preinliner import function list (llvm#85719)
By design, when the nested profile is pre-inliner based, we should fully honor pre-inliner decision, fix it by setting threshold to zero. We observed a perf win on one internal service, no negative impact for other big services.
1 parent 3a5896f commit 3f4a351

File tree

3 files changed

+67
-0
lines changed

3 files changed

+67
-0
lines changed

llvm/lib/Transforms/IPO/SampleProfile.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,6 +1167,9 @@ void SampleProfileLoader::findExternalInlineCandidate(
11671167
// For AutoFDO profile, retrieve candidate profiles by walking over
11681168
// the nested inlinee profiles.
11691169
if (!FunctionSamples::ProfileIsCS) {
1170+
// Set threshold to zero to honor pre-inliner decision.
1171+
if (UsePreInlinerDecision)
1172+
Threshold = 0;
11701173
Samples->findInlinedFunctions(InlinedGUIDs, SymbolMap, Threshold);
11711174
return;
11721175
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
main:8001:0
2+
1: 0
3+
2: 2000
4+
3: 2000
5+
4: 0
6+
5: 2000
7+
6: 2000
8+
7: 0
9+
8: 0
10+
9: bar:1
11+
1: 1
12+
!CFGChecksum: 4294967295
13+
!Attributes: 2
14+
!CFGChecksum: 563088156202820
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
; RUN: opt < %s -passes='thinlto-pre-link<O2>' -pgo-kind=pgo-sample-use-pipeline -sample-profile-file=%S/Inputs/csspgo-import-list-preinliner.prof -S -profile-summary-cutoff-hot=100000 -sample-profile-use-preinliner=0 | FileCheck %s --check-prefix=DISABLE-PREINLINE
2+
; RUN: opt < %s -passes='thinlto-pre-link<O2>' -pgo-kind=pgo-sample-use-pipeline -sample-profile-file=%S/Inputs/csspgo-import-list-preinliner.prof -S -profile-summary-cutoff-hot=100000 | FileCheck %s
3+
4+
; The GUID of bar is -2012135647395072713
5+
6+
; DISABLE-PREINLINE-NOT: -2012135647395072713
7+
; CHECK: [[#]] = !{!"function_entry_count", i64 1, i64 -2012135647395072713}
8+
9+
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
10+
target triple = "x86_64-unknown-linux-gnu"
11+
12+
define i32 @main() #0 {
13+
entry:
14+
br label %for.cond
15+
16+
for.cond: ; preds = %for.cond, %entry
17+
call void @llvm.pseudoprobe(i64 0, i64 0, i32 0, i64 0)
18+
%call2 = call i32 @bar(), !dbg !9
19+
br label %for.cond
20+
}
21+
22+
declare i32 @bar()
23+
24+
; Function Attrs: nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: readwrite)
25+
declare void @llvm.pseudoprobe(i64, i64, i32, i64) #1
26+
27+
attributes #0 = { "use-sample-profile" }
28+
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: readwrite) }
29+
30+
!llvm.dbg.cu = !{!0}
31+
!llvm.module.flags = !{!7}
32+
!llvm.pseudo_probe_desc = !{!8}
33+
34+
!0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, producer: "clang version 19.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, globals: !2, splitDebugInlining: false, nameTableKind: None)
35+
!1 = !DIFile(filename: "test.c", directory: "/home/", checksumkind: CSK_MD5, checksum: "1bff37d8b3f7858b0bc29ab4efdf9422")
36+
!2 = !{!3}
37+
!3 = !DIGlobalVariableExpression(var: !4, expr: !DIExpression())
38+
!4 = distinct !DIGlobalVariable(name: "x", scope: !0, file: !1, line: 2, type: !5, isLocal: false, isDefinition: true)
39+
!5 = !DIDerivedType(tag: DW_TAG_volatile_type, baseType: !6)
40+
!6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
41+
!7 = !{i32 2, !"Debug Info Version", i32 3}
42+
!8 = !{i64 -2624081020897602054, i64 563108639284859, !"main"}
43+
!9 = !DILocation(line: 11, column: 10, scope: !10)
44+
!10 = !DILexicalBlockFile(scope: !11, file: !1, discriminator: 186646615)
45+
!11 = distinct !DILexicalBlock(scope: !12, file: !1, line: 8, column: 40)
46+
!12 = distinct !DILexicalBlock(scope: !13, file: !1, line: 8, column: 3)
47+
!13 = distinct !DILexicalBlock(scope: !14, file: !1, line: 8, column: 3)
48+
!14 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 6, type: !15, scopeLine: 7, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !16)
49+
!15 = distinct !DISubroutineType(types: !16)
50+
!16 = !{}

0 commit comments

Comments
 (0)