1 ; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -split-machine-functions | FileCheck %s -check-prefix=MFS-DEFAULTS
2 ; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -split-machine-functions -mfs-psi-cutoff=0 -mfs-count-threshold=2000 | FileCheck %s --dump-input=always -check-prefix=MFS-OPTS1
3 ; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -split-machine-functions -mfs-psi-cutoff=950000 | FileCheck %s -check-prefix=MFS-OPTS2
5 define void @foo1(i1 zeroext %0) nounwind !prof !14 !section_prefix !15 {
6 ;; Check that cold block is moved to .text.split.
7 ; MFS-DEFAULTS-LABEL: foo1
8 ; MFS-DEFAULTS: .section .text.split.foo1
9 ; MFS-DEFAULTS-NEXT: foo1.cold:
10 ; MFS-DEFAULTS-NOT: callq bar
11 ; MFS-DEFAULTS-NEXT: callq baz
12 br i1 %0, label %2, label %4, !prof !17
23 %7 = tail call i32 @qux()
27 define void @foo2(i1 zeroext %0) nounwind !prof !23 !section_prefix !16 {
28 ;; Check that function marked unlikely is not split.
29 ; MFS-DEFAULTS-LABEL: foo2
30 ; MFS-DEFAULTS-NOT: foo2.cold:
31 br i1 %0, label %2, label %4, !prof !17
42 %7 = tail call i32 @qux()
46 define void @foo3(i1 zeroext %0) nounwind !section_prefix !15 {
47 ;; Check that function without profile data is not split.
48 ; MFS-DEFAULTS-LABEL: foo3
49 ; MFS-DEFAULTS-NOT: foo3.cold:
50 br i1 %0, label %2, label %4
61 %7 = tail call i32 @qux()
65 define void @foo4(i1 zeroext %0, i1 zeroext %1) nounwind !prof !20 {
66 ;; Check that count threshold works.
67 ; MFS-OPTS1-LABEL: foo4
68 ; MFS-OPTS1: .section .text.split.foo4
69 ; MFS-OPTS1-NEXT: foo4.cold:
70 ; MFS-OPTS1-NOT: callq bar
71 ; MFS-OPTS1-NOT: callq baz
72 ; MFS-OPTS1-NEXT: callq bam
73 br i1 %0, label %3, label %7, !prof !18
84 br i1 %1, label %8, label %10, !prof !19
95 %13 = tail call i32 @qux()
99 define void @foo5(i1 zeroext %0, i1 zeroext %1) nounwind !prof !20 {
100 ;; Check that profile summary info cutoff works.
101 ; MFS-OPTS2-LABEL: foo5
102 ; MFS-OPTS2: .section .text.split.foo5
103 ; MFS-OPTS2-NEXT: foo5.cold:
104 ; MFS-OPTS2-NOT: callq bar
105 ; MFS-OPTS2-NOT: callq baz
106 ; MFS-OPTS2-NEXT: callq bam
107 br i1 %0, label %3, label %7, !prof !21
118 br i1 %1, label %8, label %10, !prof !22
125 %11 = call i32 @baz()
129 %13 = call i32 @qux()
133 define void @foo6(i1 zeroext %0) nounwind section "nosplit" !prof !14 {
134 ;; Check that function with section attribute is not split.
135 ; MFS-DEFAULTS-LABEL: foo6
136 ; MFS-DEFAULTS-NOT: foo6.cold:
137 br i1 %0, label %2, label %4, !prof !17
148 %7 = tail call i32 @qux()
152 define i32 @foo7(i1 zeroext %0) personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) !prof !14 {
153 ;; Check that a single cold ehpad is split out.
154 ; MFS-DEFAULTS-LABEL: foo7
155 ; MFS-DEFAULTS: .section .text.split.foo7,"ax",@progbits
156 ; MFS-DEFAULTS-NEXT: foo7.cold:
157 ; MFS-DEFAULTS: callq baz
158 ; MFS-DEFAULTS: callq _Unwind_Resume@PLT
161 to label %try.cont unwind label %lpad
164 %1 = landingpad { i8*, i32 }
166 catch i8* bitcast (i8** @_ZTIi to i8*)
167 resume { i8*, i32 } %1
170 br i1 %0, label %2, label %4, !prof !17
172 2: ; preds = try.cont
181 %7 = tail call i32 @qux()
185 define i32 @foo8(i1 zeroext %0) personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) !prof !14 {
186 ;; Check that all ehpads are treated as hot if one of them is hot.
187 ; MFS-DEFAULTS-LABEL: foo8
188 ; MFS-DEFAULTS: callq _Unwind_Resume@PLT
189 ; MFS-DEFAULTS: callq _Unwind_Resume@PLT
190 ; MFS-DEFAULTS: .section .text.split.foo8,"ax",@progbits
191 ; MFS-DEFAULTS-NEXT: foo8.cold:
192 ; MFS-DEFAULTS: callq baz
195 to label %try.cont unwind label %lpad1
198 %1 = landingpad { i8*, i32 }
200 catch i8* bitcast (i8** @_ZTIi to i8*)
201 resume { i8*, i32 } %1
204 br i1 %0, label %hot, label %cold, !prof !17
209 to label %exit unwind label %lpad2, !prof !21
212 %3 = landingpad { i8*, i32 }
214 catch i8* bitcast (i8** @_ZTIi to i8*)
215 resume { i8*, i32 } %3
222 %5 = tail call i32 @qux()
226 define void @foo9(i1 zeroext %0) nounwind #0 !prof !14 {
227 ;; Check that function with section attribute is not split.
228 ; MFS-DEFAULTS-LABEL: foo9
229 ; MFS-DEFAULTS-NOT: foo9.cold:
230 br i1 %0, label %2, label %4, !prof !17
241 %7 = tail call i32 @qux()
250 declare void @_Z1fv()
251 declare i32 @__gxx_personality_v0(...)
253 @_ZTIi = external constant i8*
255 attributes #0 = { "implicit-section-name"="nosplit" }
257 !llvm.module.flags = !{!0}
258 !0 = !{i32 1, !"ProfileSummary", !1}
259 !1 = !{!2, !3, !4, !5, !6, !7, !8, !9}
260 !2 = !{!"ProfileFormat", !"InstrProf"}
261 !3 = !{!"TotalCount", i64 10000}
262 !4 = !{!"MaxCount", i64 10}
263 !5 = !{!"MaxInternalCount", i64 1}
264 !6 = !{!"MaxFunctionCount", i64 1000}
265 !7 = !{!"NumCounts", i64 3}
266 !8 = !{!"NumFunctions", i64 5}
267 !9 = !{!"DetailedSummary", !10}
268 !10 = !{!11, !12, !13}
269 !11 = !{i32 10000, i64 100, i32 1}
270 !12 = !{i32 999900, i64 100, i32 1}
271 !13 = !{i32 999999, i64 1, i32 2}
272 !14 = !{!"function_entry_count", i64 7000}
273 !15 = !{!"function_section_prefix", !"hot"}
274 !16 = !{!"function_section_prefix", !"unlikely"}
275 !17 = !{!"branch_weights", i32 7000, i32 0}
276 !18 = !{!"branch_weights", i32 3000, i32 4000}
277 !19 = !{!"branch_weights", i32 1000, i32 6000}
278 !20 = !{!"function_entry_count", i64 10000}
279 !21 = !{!"branch_weights", i32 6000, i32 4000}
280 !22 = !{!"branch_weights", i32 80, i32 9920}
281 !23 = !{!"function_entry_count", i64 7}