1 ; RUN: opt < %s -inline -S -inlinecold-threshold=25 -enable-new-pm=0 | FileCheck %s
2 ; RUN: opt < %s -passes='require<profile-summary>,cgscc(inline)' -S -inlinecold-threshold=25 | FileCheck %s
3 ; Test that functions with attribute Cold are not inlined while the
4 ; same function without attribute Cold will be inlined.
6 ; RUN: opt < %s -inline -S -inline-threshold=600 -enable-new-pm=0 | FileCheck %s -check-prefix=OVERRIDE
7 ; RUN: opt < %s -passes='require<profile-summary>,cgscc(inline)' -S -inline-threshold=600 -enable-new-pm=0 | FileCheck %s -check-prefix=OVERRIDE
8 ; The command line argument for inline-threshold should override
9 ; the default cold threshold, so a cold function with size bigger
10 ; than the default cold threshold (225) will be inlined.
12 ; RUN: opt < %s -inline -S -enable-new-pm=0 | FileCheck %s -check-prefix=DEFAULT
13 ; RUN: opt < %s -passes='require<profile-summary>,cgscc(inline)' -S | FileCheck %s -check-prefix=DEFAULT
14 ; The same cold function will not be inlined with the default behavior.
18 ; This function should be larger than the cold threshold (75), but smaller
19 ; than the regular threshold.
20 ; Function Attrs: nounwind readnone uwtable
21 define i32 @simpleFunction(i32 %a) #0 {
24 %a1 = load volatile i32, i32* @a
25 %x1 = add i32 %a1, %a1
26 %a2 = load volatile i32, i32* @a
27 %x2 = add i32 %x1, %a2
28 %a3 = load volatile i32, i32* @a
29 %x3 = add i32 %x2, %a3
30 %a4 = load volatile i32, i32* @a
31 %x4 = add i32 %x3, %a4
32 %a5 = load volatile i32, i32* @a
33 %x5 = add i32 %x4, %a5
34 %a6 = load volatile i32, i32* @a
35 %x6 = add i32 %x5, %a6
36 %a7 = load volatile i32, i32* @a
37 %x7 = add i32 %x6, %a6
38 %a8 = load volatile i32, i32* @a
39 %x8 = add i32 %x7, %a8
40 %a9 = load volatile i32, i32* @a
41 %x9 = add i32 %x8, %a9
42 %a10 = load volatile i32, i32* @a
43 %x10 = add i32 %x9, %a10
44 %a11 = load volatile i32, i32* @a
45 %x11 = add i32 %x10, %a11
46 %a12 = load volatile i32, i32* @a
47 %x12 = add i32 %x11, %a12
48 %add = add i32 %x12, %a
52 ; Function Attrs: nounwind cold readnone uwtable
53 define i32 @ColdFunction(i32 %a) #1 {
54 ; CHECK-LABEL: @ColdFunction
56 ; OVERRIDE-LABEL: @ColdFunction
58 ; DEFAULT-LABEL: @ColdFunction
62 %a1 = load volatile i32, i32* @a
63 %x1 = add i32 %a1, %a1
64 %a2 = load volatile i32, i32* @a
65 %x2 = add i32 %x1, %a2
66 %a3 = load volatile i32, i32* @a
67 %x3 = add i32 %x2, %a3
68 %a4 = load volatile i32, i32* @a
69 %x4 = add i32 %x3, %a4
70 %add = add i32 %x4, %a
74 ; This function should be larger than the default cold threshold (225).
75 define i32 @ColdFunction2(i32 %a) #1 {
76 ; CHECK-LABEL: @ColdFunction2
78 ; OVERRIDE-LABEL: @ColdFunction2
80 ; DEFAULT-LABEL: @ColdFunction2
84 %a1 = load volatile i32, i32* @a
85 %x1 = add i32 %a1, %a1
86 %a2 = load volatile i32, i32* @a
87 %x2 = add i32 %x1, %a2
88 %a3 = load volatile i32, i32* @a
89 %x3 = add i32 %x2, %a3
90 %a4 = load volatile i32, i32* @a
91 %x4 = add i32 %x3, %a4
92 %a5 = load volatile i32, i32* @a
93 %x5 = add i32 %x4, %a5
94 %a6 = load volatile i32, i32* @a
95 %x6 = add i32 %x5, %a6
96 %a7 = load volatile i32, i32* @a
97 %x7 = add i32 %x6, %a7
98 %a8 = load volatile i32, i32* @a
99 %x8 = add i32 %x7, %a8
100 %a9 = load volatile i32, i32* @a
101 %x9 = add i32 %x8, %a9
102 %a10 = load volatile i32, i32* @a
103 %x10 = add i32 %x9, %a10
104 %a11 = load volatile i32, i32* @a
105 %x11 = add i32 %x10, %a11
106 %a12 = load volatile i32, i32* @a
107 %x12 = add i32 %x11, %a12
109 %a21 = load volatile i32, i32* @a
110 %x21 = add i32 %x12, %a21
111 %a22 = load volatile i32, i32* @a
112 %x22 = add i32 %x21, %a22
113 %a23 = load volatile i32, i32* @a
114 %x23 = add i32 %x22, %a23
115 %a24 = load volatile i32, i32* @a
116 %x24 = add i32 %x23, %a24
117 %a25 = load volatile i32, i32* @a
118 %x25 = add i32 %x24, %a25
119 %a26 = load volatile i32, i32* @a
120 %x26 = add i32 %x25, %a26
121 %a27 = load volatile i32, i32* @a
122 %x27 = add i32 %x26, %a27
123 %a28 = load volatile i32, i32* @a
124 %x28 = add i32 %x27, %a28
125 %a29 = load volatile i32, i32* @a
126 %x29 = add i32 %x28, %a29
127 %a30 = load volatile i32, i32* @a
128 %x30 = add i32 %x29, %a30
129 %a31 = load volatile i32, i32* @a
130 %x31 = add i32 %x30, %a31
131 %a32 = load volatile i32, i32* @a
132 %x32 = add i32 %x31, %a32
134 %a41 = load volatile i32, i32* @a
135 %x41 = add i32 %x32, %a41
136 %a42 = load volatile i32, i32* @a
137 %x42 = add i32 %x41, %a42
138 %a43 = load volatile i32, i32* @a
139 %x43 = add i32 %x42, %a43
140 %a44 = load volatile i32, i32* @a
141 %x44 = add i32 %x43, %a44
142 %a45 = load volatile i32, i32* @a
143 %x45 = add i32 %x44, %a45
144 %a46 = load volatile i32, i32* @a
145 %x46 = add i32 %x45, %a46
146 %a47 = load volatile i32, i32* @a
147 %x47 = add i32 %x46, %a47
148 %a48 = load volatile i32, i32* @a
149 %x48 = add i32 %x47, %a48
150 %a49 = load volatile i32, i32* @a
151 %x49 = add i32 %x48, %a49
152 %a50 = load volatile i32, i32* @a
153 %x50 = add i32 %x49, %a50
154 %a51 = load volatile i32, i32* @a
155 %x51 = add i32 %x50, %a51
156 %a52 = load volatile i32, i32* @a
157 %x52 = add i32 %x51, %a52
159 %add = add i32 %x52, %a
163 ; Function Attrs: nounwind readnone uwtable
164 define i32 @bar(i32 %a) #0 {
166 ; CHECK: call i32 @ColdFunction(i32 5)
167 ; CHECK-NOT: call i32 @simpleFunction(i32 6)
168 ; CHECK: call i32 @ColdFunction2(i32 5)
170 ; OVERRIDE-LABEL: @bar
171 ; OVERRIDE-NOT: call i32 @ColdFunction(i32 5)
172 ; OVERRIDE-NOT: call i32 @simpleFunction(i32 6)
173 ; OVERRIDE-NOT: call i32 @ColdFunction2(i32 5)
175 ; DEFAULT-LABEL: @bar
176 ; DEFAULT-NOT: call i32 @ColdFunction(i32 5)
177 ; DEFAULT-NOT: call i32 @simpleFunction(i32 6)
178 ; DEFAULT: call i32 @ColdFunction2(i32 5)
181 %0 = tail call i32 @ColdFunction(i32 5)
182 %1 = tail call i32 @simpleFunction(i32 6)
183 %2 = tail call i32 @ColdFunction2(i32 5)
185 %add = add i32 %2, %3
189 declare void @extern()
190 attributes #0 = { nounwind readnone uwtable }
191 attributes #1 = { nounwind cold readnone uwtable }