• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; This tests that a hot callsite gets the (higher) inlinehint-threshold even without
2; without inline hints and gets inlined because the cost is less than
3; inlinehint-threshold. A cold callee with identical body does not get inlined because
4; cost exceeds the inline-threshold
5
6; RUN: opt < %s -inline -inline-threshold=0 -hot-callsite-threshold=100 -S -enable-new-pm=0 | FileCheck %s
7; RUN: opt < %s -passes='require<profile-summary>,cgscc(inline)' -inline-threshold=0 -hot-callsite-threshold=100 -S | FileCheck %s
8
9; Run this with the default O2 pipeline to test that profile summary analysis
10; is available during inlining.
11; RUN: opt < %s -passes='default<O2>' -inline-threshold=0 -hot-callsite-threshold=100 -S | FileCheck %s
12
13define i32 @callee1(i32 %x) {
14  %x1 = add i32 %x, 1
15  %x2 = add i32 %x1, 1
16  %x3 = add i32 %x2, 1
17  call void @extern()
18  call void @extern()
19  ret i32 %x3
20}
21
22define i32 @callee2(i32 %x) {
23; CHECK-LABEL: @callee2(
24  %x1 = add i32 %x, 1
25  %x2 = add i32 %x1, 1
26  %x3 = add i32 %x2, 1
27  call void @extern()
28  call void @extern()
29  ret i32 %x3
30}
31
32define i32 @caller2(i32 %y1) {
33; CHECK-LABEL: @caller2(
34; CHECK: call i32 @callee2
35; CHECK-NOT: call i32 @callee1
36; CHECK: ret i32 %x3.i
37  %y2 = call i32 @callee2(i32 %y1), !prof !22
38  %y3 = call i32 @callee1(i32 %y2), !prof !21
39  ret i32 %y3
40}
41
42declare i32 @__gxx_personality_v0(...)
43
44define i32 @invoker2(i32 %y1) personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
45; CHECK-LABEL: @invoker2(
46; CHECK: invoke i32 @callee2
47; CHECK-NOT: invoke i32 @callee1
48; CHECK: ret i32
49  %y2 = invoke i32 @callee2(i32 %y1) to label %next unwind label %lpad, !prof !22
50
51next:
52  %y3 = invoke i32 @callee1(i32 %y2) to label %exit unwind label %lpad, !prof !21
53
54exit:
55  ret i32 1
56
57lpad:
58  %ll = landingpad { i8*, i32 } cleanup
59  ret i32 1
60}
61
62define i32 @invoker3(i32 %y1) personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
63; CHECK-LABEL: @invoker3(
64; CHECK: invoke i32 @callee2
65; CHECK-NOT: invoke i32 @callee1
66; CHECK: ret i32
67  %y2 = invoke i32 @callee2(i32 %y1) to label %next unwind label %lpad,
68          !prof !{!"branch_weights", i64 1, i64 0}
69
70next:
71  %y3 = invoke i32 @callee1(i32 %y2) to label %exit unwind label %lpad,
72          !prof !{!"branch_weights", i64 300, i64 1}
73
74exit:
75  ret i32 1
76
77lpad:
78  %ll = landingpad { i8*, i32 } cleanup
79  ret i32 1
80}
81
82define i32 @invoker4(i32 %y1) personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
83; CHECK-LABEL: @invoker4(
84; CHECK: invoke i32 @callee2
85; CHECK-NOT: invoke i32 @callee1
86; CHECK: ret i32
87  %y2 = invoke i32 @callee2(i32 %y1) to label %next unwind label %lpad,
88          !prof !{!"branch_weights", i64 1, i64 0}
89
90next:
91  %y3 = invoke i32 @callee1(i32 %y2) to label %exit unwind label %lpad,
92          !prof !{!"branch_weights", i64 0, i64 300}
93
94exit:
95  ret i32 1
96
97lpad:
98  %ll = landingpad { i8*, i32 } cleanup
99  ret i32 1
100}
101
102declare void @extern()
103
104!llvm.module.flags = !{!1}
105!21 = !{!"branch_weights", i64 300}
106!22 = !{!"branch_weights", i64 1}
107
108!1 = !{i32 1, !"ProfileSummary", !2}
109!2 = !{!3, !4, !5, !6, !7, !8, !9, !10}
110!3 = !{!"ProfileFormat", !"SampleProfile"}
111!4 = !{!"TotalCount", i64 10000}
112!5 = !{!"MaxCount", i64 1000}
113!6 = !{!"MaxInternalCount", i64 1}
114!7 = !{!"MaxFunctionCount", i64 1000}
115!8 = !{!"NumCounts", i64 3}
116!9 = !{!"NumFunctions", i64 3}
117!10 = !{!"DetailedSummary", !11}
118!11 = !{!12, !13, !14}
119!12 = !{i32 10000, i64 100, i32 1}
120!13 = !{i32 999000, i64 100, i32 1}
121!14 = !{i32 999999, i64 1, i32 2}
122