xref: /llvm-project/llvm/test/Transforms/Inline/inline-cold-callsite-pgo.ll (revision 5c97507e2b67ee9194d7eb0a8162ec86ce12afc3)
1; RUN: opt < %s -passes='require<profile-summary>,cgscc(inline)' -inline-threshold=100 -inline-cold-callsite-threshold=0 -S | FileCheck %s
2
3; This tests that a cold callsite gets the inline-cold-callsite-threshold
4; and does not get inlined. Another callsite to an identical callee that
5; is not cold gets inlined because cost is below the inline-threshold.
6
7define i32 @callee1(i32 %x) "function-inline-cost"="30" !prof !21 {
8  %x1 = add i32 %x, 1
9  call void @extern()
10  ret i32 %x1
11}
12
13define i32 @caller(i32 %n) !prof !22 {
14; CHECK-LABEL: @caller(
15  %cond = icmp sle i32 %n, 100
16  br i1 %cond, label %cond_true, label %cond_false, !prof !0
17
18cond_true:
19; CHECK-LABEL: cond_true:
20; CHECK-NOT: call i32 @callee1
21; CHECK: ret i32 %x1.i
22  %i = call i32 @callee1(i32 %n)
23  ret i32 %i
24cond_false:
25; CHECK-LABEL: cond_false:
26; CHECK: call i32 @callee1
27; CHECK: ret i32 %j
28  %j = call i32 @callee1(i32 %n)
29  ret i32 %j
30}
31declare void @extern()
32
33!0 = !{!"branch_weights", i32 200, i32 1}
34
35!llvm.module.flags = !{!1}
36!21 = !{!"function_entry_count", i64 200}
37!22 = !{!"function_entry_count", i64 200}
38
39!1 = !{i32 1, !"ProfileSummary", !2}
40!2 = !{!3, !4, !5, !6, !7, !8, !9, !10}
41!3 = !{!"ProfileFormat", !"InstrProf"}
42!4 = !{!"TotalCount", i64 10000}
43!5 = !{!"MaxCount", i64 1000}
44!6 = !{!"MaxInternalCount", i64 1}
45!7 = !{!"MaxFunctionCount", i64 1000}
46!8 = !{!"NumCounts", i64 3}
47!9 = !{!"NumFunctions", i64 3}
48!10 = !{!"DetailedSummary", !11}
49!11 = !{!12, !13, !14}
50!12 = !{i32 10000, i64 1000, i32 1}
51!13 = !{i32 999000, i64 1000, i32 1}
52!14 = !{i32 999999, i64 1, i32 2}
53