1; RUN: opt < %s -passes='require<profile-summary>,cgscc(inline)' -inline-threshold=0 -inlinehint-threshold=0 -hot-callsite-threshold=100 -S | FileCheck %s
2
3; This tests that a callsite which is determined to be hot based on the caller's
4; entry count and the callsite block frequency gets the hot-callsite-threshold.
5; Another callsite with the same callee that is not hot does not get inlined
6; because cost exceeds the inline-threshold. inlinthint-threshold is set to 0
7; to ensure callee's hotness is not used to boost the threshold.
8
9define i32 @callee1(i32 %x) !prof !21 {
10  %x1 = add i32 %x, 1
11  %x2 = add i32 %x1, 1
12  %x3 = add i32 %x2, 1
13  call void @extern()
14  ret i32 %x3
15}
16
17define i32 @caller(i32 %n) !prof !22 {
18; CHECK-LABEL: @caller(
19  %cond = icmp sle i32 %n, 100
20  br i1 %cond, label %cond_true, label %cond_false, !prof !0
21
22cond_true:
23; CHECK-LABEL: cond_true:
24; CHECK-NOT: call i32 @callee1
25; CHECK: ret i32 %x3.i
26  %i = call i32 @callee1(i32 %n)
27  ret i32 %i
28cond_false:
29; CHECK-LABEL: cond_false:
30; CHECK: call i32 @callee1
31; CHECK: ret i32 %j
32  %j = call i32 @callee1(i32 %n)
33  ret i32 %j
34}
35declare void @extern()
36
37!0 = !{!"branch_weights", i32 64, i32 4}
38
39!llvm.module.flags = !{!1}
40!21 = !{!"function_entry_count", i64 200}
41!22 = !{!"function_entry_count", i64 200}
42
43!1 = !{i32 1, !"ProfileSummary", !2}
44!2 = !{!3, !4, !5, !6, !7, !8, !9, !10}
45!3 = !{!"ProfileFormat", !"InstrProf"}
46!4 = !{!"TotalCount", i64 10000}
47!5 = !{!"MaxCount", i64 1000}
48!6 = !{!"MaxInternalCount", i64 1}
49!7 = !{!"MaxFunctionCount", i64 1000}
50!8 = !{!"NumCounts", i64 3}
51!9 = !{!"NumFunctions", i64 3}
52!10 = !{!"DetailedSummary", !11}
53!11 = !{!12, !13, !14}
54!12 = !{i32 10000, i64 100, i32 1}
55!13 = !{i32 999000, i64 100, i32 1}
56!14 = !{i32 999999, i64 1, i32 2}
57