1; RUN: opt < %s -inline -inlinecold-threshold=0 -S | FileCheck %s
2
3; This tests that a cold callee gets the (lower) inlinecold-threshold even without
4; Cold hint and does not get inlined because the cost exceeds the inlinecold-threshold.
5; A callee with identical body does gets inlined because cost fits within the
6; inline-threshold
7
8define i32 @callee1(i32 %x) !prof !21 {
9  %x1 = add i32 %x, 1
10  %x2 = add i32 %x1, 1
11  %x3 = add i32 %x2, 1
12  call void @extern()
13  ret i32 %x3
14}
15
16define i32 @callee2(i32 %x) !prof !22 {
17; CHECK-LABEL: @callee2(
18  %x1 = add i32 %x, 1
19  %x2 = add i32 %x1, 1
20  %x3 = add i32 %x2, 1
21  call void @extern()
22  ret i32 %x3
23}
24
25define i32 @caller2(i32 %y1) !prof !22 {
26; CHECK-LABEL: @caller2(
27; CHECK: call i32 @callee2
28; CHECK-NOT: call i32 @callee1
29; CHECK: ret i32 %x3.i
30  %y2 = call i32 @callee2(i32 %y1)
31  %y3 = call i32 @callee1(i32 %y2)
32  ret i32 %y3
33}
34
35declare void @extern()
36
37!llvm.module.flags = !{!1}
38!21 = !{!"function_entry_count", i64 100}
39!22 = !{!"function_entry_count", i64 1}
40
41!1 = !{i32 1, !"ProfileSummary", !2}
42!2 = !{!3, !4, !5, !6, !7, !8, !9, !10}
43!3 = !{!"ProfileFormat", !"InstrProf"}
44!4 = !{!"TotalCount", i64 10000}
45!5 = !{!"MaxCount", i64 1000}
46!6 = !{!"MaxInternalCount", i64 1}
47!7 = !{!"MaxFunctionCount", i64 1000}
48!8 = !{!"NumCounts", i64 3}
49!9 = !{!"NumFunctions", i64 3}
50!10 = !{!"DetailedSummary", !11}
51!11 = !{!12, !13, !14}
52!12 = !{i32 10000, i64 100, i32 1}
53!13 = !{i32 999000, i64 100, i32 1}
54!14 = !{i32 999999, i64 1, i32 2}
55