xref: /llvm-project/llvm/test/CodeGen/Generic/machine-function-splitter.ll (revision 68f7b075c07197803625431ba92c337af7470c85)
1; REQUIRES: aarch64-registered-target
2; REQUIRES: x86-registered-target
3
4; COM: Machine function splitting with FDO profiles
5; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -split-machine-functions | FileCheck %s -check-prefixes=MFS-DEFAULTS,MFS-DEFAULTS-X86,MFS-NOBBSECTIONS
6; 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-prefixes=MFS-OPTS1,MFS-OPTS1-X86
7; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -split-machine-functions -mfs-psi-cutoff=950000 | FileCheck %s -check-prefixes=MFS-OPTS2,MFS-OPTS2-X86
8; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -split-machine-functions -mfs-split-ehcode | FileCheck %s -check-prefixes=MFS-EH-SPLIT,MFS-EH-SPLIT-X86
9; RUN: llc < %s -mtriple=x86_64 -split-machine-functions -O0 -mfs-psi-cutoff=0 -mfs-count-threshold=10000 | FileCheck %s -check-prefixes=MFS-O0,MFS-O0-X86
10
11; COM: Machine function splitting along with -basic-block-sections profile
12; RUN: echo 'v1' > %t
13; RUN: echo 'ffoo21' >> %t
14; RUN: echo 'c0' >> %t
15; RUN: echo 'ffoo22' >> %t
16; RUN: echo 'c0 1' >> %t
17; RUN: echo 'c2' >> %t
18; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -basic-block-sections=%t -split-machine-functions | FileCheck %s --check-prefixes=MFS-BBSECTIONS
19
20; RUN: llc < %s -mtriple=aarch64-unknown-linux-gnu -aarch64-min-jump-table-entries=4 -enable-split-machine-functions | FileCheck %s -check-prefixes=MFS-DEFAULTS,MFS-DEFAULTS-AARCH64
21; RUN: llc < %s -mtriple=aarch64-unknown-linux-gnu -aarch64-min-jump-table-entries=4 -enable-split-machine-functions -mfs-psi-cutoff=0 -mfs-count-threshold=2000 | FileCheck %s --dump-input=always -check-prefixes=MFS-OPTS1,MFS-OPTS1-AARCH64
22; RUN: llc < %s -mtriple=aarch64-unknown-linux-gnu -aarch64-min-jump-table-entries=4 -enable-split-machine-functions -mfs-psi-cutoff=950000 | FileCheck %s -check-prefixes=MFS-OPTS2,MFS-OPTS2-AARCH64
23; RUN: llc < %s -mtriple=aarch64-unknown-linux-gnu -aarch64-min-jump-table-entries=4 -enable-split-machine-functions -mfs-split-ehcode | FileCheck %s -check-prefixes=MFS-EH-SPLIT,MFS-EH-SPLIT-AARCH64
24; RUN: llc < %s -mtriple=aarch64 -split-machine-functions -O0 -mfs-psi-cutoff=0 -mfs-count-threshold=10000 | FileCheck %s -check-prefixes=MFS-O0,MFS-O0-AARCH64
25; RUN: llc < %s -mtriple=aarch64 -enable-split-machine-functions -aarch64-redzone | FileCheck %s -check-prefixes=MFS-REDZONE-AARCH64
26
27; COM: Machine function splitting with AFDO profiles
28; RUN: sed 's/InstrProf/SampleProfile/g' %s > %t.ll
29; RUN: llc < %t.ll -mtriple=x86_64-unknown-linux-gnu -split-machine-functions | FileCheck %s --check-prefix=FSAFDO-MFS
30; RUN: llc < %t.ll -mtriple=x86_64-unknown-linux-gnu -split-machine-functions | FileCheck %s --check-prefix=FSAFDO-MFS2
31
32define void @foo1(i1 zeroext %0) nounwind !prof !14 !section_prefix !15 {
33;; Check that cold block is moved to .text.split.
34; MFS-DEFAULTS-LABEL:         foo1
35; MFS-DEFAULTS:               .section        .text.split.foo1
36; MFS-DEFAULTS-NEXT:          foo1.cold:
37; MFS-DEFAULTS-X86-NOT:       callq   bar
38; MFS-DEFAULTS-X86-NEXT:      callq   baz
39; MFS-DEFAULTS-AARCH64-NOT:   bl      bar
40; MFS-DEFAULTS-AARCH64-NEXT:  bl      baz
41  br i1 %0, label %2, label %4, !prof !17
42
432:                                                ; preds = %1
44  %3 = call i32 @bar()
45  br label %6
46
474:                                                ; preds = %1
48  %5 = call i32 @baz()
49  br label %6
50
516:                                                ; preds = %4, %2
52  %7 = tail call i32 @qux()
53  ret void
54}
55
56define void @foo2(i1 zeroext %0) nounwind !prof !23 !section_prefix !16 {
57;; Check that function marked unlikely is not split.
58; MFS-DEFAULTS-LABEL: foo2
59; MFS-DEFAULTS-NOT:   foo2.cold:
60  br i1 %0, label %2, label %4, !prof !17
61
622:                                                ; preds = %1
63  %3 = call i32 @bar()
64  br label %6
65
664:                                                ; preds = %1
67  %5 = call i32 @baz()
68  br label %6
69
706:                                                ; preds = %4, %2
71  %7 = tail call i32 @qux()
72  ret void
73}
74
75define void @foo3(i1 zeroext %0) nounwind !section_prefix !15 {
76;; Check that function without profile data is not split.
77; MFS-DEFAULTS-LABEL: foo3
78; MFS-DEFAULTS-NOT:   foo3.cold:
79  br i1 %0, label %2, label %4
80
812:                                                ; preds = %1
82  %3 = call i32 @bar()
83  br label %6
84
854:                                                ; preds = %1
86  %5 = call i32 @baz()
87  br label %6
88
896:                                                ; preds = %4, %2
90  %7 = tail call i32 @qux()
91  ret void
92}
93
94define void @foo4(i1 zeroext %0, i1 zeroext %1) nounwind !prof !20 {
95;; Check that count threshold works.
96; MFS-OPTS1-LABEL:         foo4
97; MFS-OPTS1:               .section        .text.split.foo4
98; MFS-OPTS1-NEXT:          foo4.cold:
99; MFS-OPTS1-X86-NOT:       callq    bar
100; MFS-OPTS1-X86-NOT:       callq    baz
101; MFS-OPTS1-X86-NEXT:      callq    bam
102; MFS-OPTS1-AARCH64-NOT:   bl       bar
103; MFS-OPTS1-AARCH64-NOT:   bl       baz
104; MFS-OPTS1-AARCH64-NEXT:  bl       bam
105  br i1 %0, label %3, label %7, !prof !18
106
1073:
108  %4 = call i32 @bar()
109  br label %7
110
1115:
112  %6 = call i32 @baz()
113  br label %7
114
1157:
116  br i1 %1, label %8, label %10, !prof !19
117
1188:
119  %9 = call i32 @bam()
120  br label %12
121
12210:
123  %11 = call i32 @baz()
124  br label %12
125
12612:
127  %13 = tail call i32 @qux()
128  ret void
129}
130
131define void @foo5(i1 zeroext %0, i1 zeroext %1) nounwind !prof !20 {
132;; Check that profile summary info cutoff works.
133; MFS-OPTS2-LABEL:         foo5
134; MFS-OPTS2:               .section        .text.split.foo5
135; MFS-OPTS2-NEXT:               foo5.cold:
136; MFS-OPTS2-X86-NOT:       callq    bar
137; MFS-OPTS2-X86-NOT:       callq    baz
138; MFS-OPTS2-X86-NEXT:      callq    bam
139; MFS-OPTS2-AARCH64-NOT:   bl       bar
140; MFS-OPTS2-AARCH64-NOT:   bl       baz
141; MFS-OPTS2-AARCH64-NEXT:  bl       bam
142  br i1 %0, label %3, label %7, !prof !21
143
1443:
145  %4 = call i32 @bar()
146  br label %7
147
1485:
149  %6 = call i32 @baz()
150  br label %7
151
1527:
153  br i1 %1, label %8, label %10, !prof !22
154
1558:
156  %9 = call i32 @bam()
157  br label %12
158
15910:
160  %11 = call i32 @baz()
161  br label %12
162
16312:
164  %13 = call i32 @qux()
165  ret void
166}
167
168define void @foo6(i1 zeroext %0) nounwind section "nosplit" !prof !14 {
169;; Check that function with section attribute is not split.
170; MFS-DEFAULTS-LABEL: foo6
171; MFS-DEFAULTS-NOT:   foo6.cold:
172  br i1 %0, label %2, label %4, !prof !17
173
1742:                                                ; preds = %1
175  %3 = call i32 @bar()
176  br label %6
177
1784:                                                ; preds = %1
179  %5 = call i32 @baz()
180  br label %6
181
1826:                                                ; preds = %4, %2
183  %7 = tail call i32 @qux()
184  ret void
185}
186
187define i32 @foo7(i1 zeroext %0) personality ptr @__gxx_personality_v0 !prof !14 {
188;; Check that a single cold ehpad is split out.
189; MFS-DEFAULTS-LABEL:         foo7
190; MFS-DEFAULTS:               .section        .text.split.foo7,"ax",@progbits
191; MFS-DEFAULTS-NEXT:          foo7.cold:
192; MFS-DEFAULTS-X86:           callq   baz
193; MFS-DEFAULTS-X86:           callq   _Unwind_Resume@PLT
194; MFS-DEFAULTS-AARCH64:       bl      baz
195entry:
196  invoke void @_Z1fv()
197          to label %try.cont unwind label %lpad
198
199lpad:
200  %1 = landingpad { ptr, i32 }
201          cleanup
202          catch ptr @_ZTIi
203  resume { ptr, i32 } %1
204
205try.cont:
206  br i1 %0, label %2, label %4, !prof !17
207
2082:                                                ; preds = try.cont
209  %3 = call i32 @bar()
210  br label %6
211
2124:                                                ; preds = %1
213  %5 = call i32 @baz()
214  br label %6
215
2166:                                                ; preds = %4, %2
217  %7 = tail call i32 @qux()
218  ret i32 %7
219}
220
221define i32 @foo8(i1 zeroext %0) personality ptr @__gxx_personality_v0 !prof !14 {
222;; Check that all ehpads are treated as hot if one of them is hot.
223; MFS-DEFAULTS-LABEL:         foo8
224; MFS-DEFAULTS-X86:           callq   _Unwind_Resume@PLT
225; MFS-DEFAULTS-X86:           callq   _Unwind_Resume@PLT
226; MFS-DEFAULTS:               .section        .text.split.foo8,"ax",@progbits
227; MFS-DEFAULTS-NEXT:          foo8.cold:
228; MFS-DEFAULTS-X86:           callq   baz
229; MFS-DEFAULTS-AARCH64:       bl      baz
230
231;; Check that all ehpads are by default treated as cold with -mfs-split-ehcode.
232; MFS-EH-SPLIT-LABEL:         foo8
233; MFS-EH-SPLIT-X86:           callq   baz
234; MFS-EH-SPLIT-AARCH64:       bl      baz
235; MFS-EH-SPLIT-X86:           .section        .text.split.foo8,"ax",@progbits
236; MFS-EH-SPLIT-X86-NEXT:      foo8.cold:
237; MFS-EH-SPLIT-X86:           callq   _Unwind_Resume@PLT
238; MFS-EH-SPLIT-X86:           callq   _Unwind_Resume@PLT
239entry:
240  invoke void @_Z1fv()
241          to label %try.cont unwind label %lpad1
242
243lpad1:
244  %1 = landingpad { ptr, i32 }
245          cleanup
246          catch ptr @_ZTIi
247  resume { ptr, i32 } %1
248
249try.cont:
250  br i1 %0, label %hot, label %cold, !prof !17
251
252hot:
253  %2 = call i32 @bar()
254  invoke void @_Z1fv()
255          to label %exit unwind label %lpad2, !prof !21
256
257lpad2:
258  %3 = landingpad { ptr, i32 }
259          cleanup
260          catch ptr @_ZTIi
261  resume { ptr, i32 } %3
262
263cold:
264  %4 = call i32 @baz()
265  br label %exit
266
267exit:
268  %5 = tail call i32 @qux()
269  ret i32 %5
270}
271
272define i32 @foo10(i1 zeroext %0) personality ptr @__gxx_personality_v0 !prof !14 {
273;; Check that nop is inserted just before the EH pad if it's beginning a section.
274; MFS-DEFAULTS-LABEL:         foo10
275; MFS-DEFAULTS-X86-LABEL:     callq   baz
276; MFS-DEFAULTS-AARCH64:       bl      baz
277; MFS-DEFAULTS-X86:           .section        .text.split.foo10,"ax",@progbits
278; MFS-DEFAULTS-X86-NEXT:      foo10.cold:
279; MFS-DEFAULTS-X86:           nop
280; MFS-DEFAULTS-X86:           callq   _Unwind_Resume@PLT
281entry:
282  invoke void @_Z1fv()
283          to label %try.cont unwind label %lpad, !prof !17
284
285lpad:
286  %1 = landingpad { ptr, i32 }
287          cleanup
288          catch ptr @_ZTIi
289  resume { ptr, i32 } %1
290
291try.cont:
292  %2 = call i32 @baz()
293  ret i32 %2
294}
295
296define void @foo11(i1 zeroext %0) personality ptr @__gxx_personality_v0 {
297;; Check that function having landing pads are split with mfs-split-ehcode
298;; even in the absence of profile data
299; MFS-EH-SPLIT-LABEL:         foo11
300; MFS-EH-SPLIT-X86:           .section        .text.split.foo11,"ax",@progbits
301; MFS-EH-SPLIT-X86-NEXT:      foo11.cold:
302; MFS-EH-SPLIT-X86:           nop
303; MFS-EH-SPLIT-X86:           callq   _Unwind_Resume@PLT
304entry:
305  invoke void @_Z1fv()
306        to label %2 unwind label %lpad
307
308lpad:
309  %1 = landingpad { ptr, i32 }
310          cleanup
311          catch ptr @_ZTIi
312  resume { ptr, i32 } %1
313
3142:                                                ; preds = entry
315  %3 = tail call i32 @qux()
316  ret void
317}
318
319define i32 @foo12(i1 zeroext %0) personality ptr @__gxx_personality_v0 !prof !14 {
320;; Check that all code reachable from ehpad is split out with cycles.
321; MFS-EH-SPLIT-LABEL:         foo12
322; MFS-EH-SPLIT:               .section        .text.split.foo12,"ax",@progbits
323; MFS-EH-SPLIT-NEXT:          foo12.cold:
324; MFS-EH-SPLIT-X86:           callq   bar
325; MFS-EH-SPLIT-X86:           callq   baz
326; MFS-EH-SPLIT-X86:           callq   qux
327; MFS-EH-SPLIT-AARCH64:       bl      bar
328; MFS-EH-SPLIT-AARCH64:       bl      baz
329; MFS-EH-SPLIT-AARCH64:       bl      qux
330entry:
331  invoke void @_Z1fv()
332          to label %8 unwind label %lpad
333
334lpad:
335  %1 = landingpad { ptr, i32 }
336          cleanup
337          catch ptr @_ZTIi
338  br label %2
339
3402:                                                ; preds = lpad
341  %3 = call i32 @bar()
342  br i1 %0, label %4, label %6
343
3444:                                                ; preds = lpad
345  %5 = call i32 @baz()
346  br label %6
347
3486:                                                ; preds = %4, %2
349  %7 = tail call i32 @qux()
350  br i1 %0, label %2, label %8
351
3528:                                                ; preds = %6
353  ret i32 0
354}
355
356define i32 @foo13(i1 zeroext %0) personality ptr @__gxx_personality_v0 !prof !14{
357;; Check that all code reachable from EH
358;; that is also reachable from outside EH pad
359;; is not touched.
360; MFS-EH-SPLIT-LABEL:         foo13
361; MFS-EH-SPLIT-X86:           callq   bam
362; MFS-EH-SPLIT-AARCH64:       bl      bam
363; MFS-EH-SPLIT:               .section        .text.split.foo13,"ax",@progbits
364; MFS-EH-SPLIT-NEXT:          foo13.cold:
365; MFS-EH-SPLIT-X86:           callq   baz
366; MFS-EH-SPLIT-X86:           callq   bar
367; MFS-EH-SPLIT-X86:           callq   qux
368; MFS-EH-SPLIT-AARCH64:       bl      baz
369; MFS-EH-SPLIT-AARCH64:       bl      bar
370; MFS-EH-SPLIT-AARCH64:       bl      qux
371entry:
372  invoke void @_Z1fv()
373          to label %try.cont unwind label %lpad, !prof !17
374
375lpad:
376  %1 = landingpad { ptr, i32 }
377          cleanup
378          catch ptr @_ZTIi
379  br i1 %0, label %2, label %4, !prof !17
380
3812:                                                ; preds = lpad
382  %3 = call i32 @bar()
383  br label %6
384
3854:                                                ; preds = lpad
386  %5 = call i32 @baz()
387  br label %6
388
3896:                                                ; preds = %4, %2
390  %7 = tail call i32 @qux()
391  br i1 %0, label %2, label %try.cont, !prof !17
392
393try.cont:                                        ; preds = %entry
394  %8 = call i32 @bam()
395  ret i32 %8
396}
397
398define void @foo14(i1 zeroext %0, i1 zeroext %1) nounwind !prof !24 {
399; FSAFDO-MFS: .section	.text.split.foo14,"ax"
400; FSAFDO-MFS: foo14.cold:
401  br i1 %0, label %3, label %7, !prof !25
402
4033:
404  %4 = call i32 @bar()
405  br label %7
406
4075:
408  %6 = call i32 @baz()
409  br label %7
410
4117:
412  br i1 %1, label %8, label %10, !prof !26
413
4148:
415  %9 = call i32 @bam()
416  br label %12
417
41810:
419  %11 = call i32 @baz()
420  br label %12
421
42212:
423  %13 = tail call i32 @qux()
424  ret void
425}
426
427define void @foo15(i1 zeroext %0, i1 zeroext %1) nounwind !prof !27 {
428;; HasAccurateProfile is false, foo15 is hot, but no profile data for
429;; blocks, no split should happen.
430; FSAFDO-MFS2-NOT: .section	.text.split.foo15,"ax"
431; FSAFDO-MFS2-NOT: foo15.cold:
432  br i1 %0, label %3, label %7
433
4343:
435  %4 = call i32 @bar()
436  br label %7
437
4385:
439  %6 = call i32 @baz()
440  br label %7
441
4427:
443  br i1 %1, label %8, label %10
444
4458:
446  %9 = call i32 @bam()
447  br label %12
448
44910:
450  %11 = call i32 @baz()
451  br label %12
452
45312:
454  %13 = tail call i32 @qux()
455  ret void
456}
457
458define void @foo16(i1 zeroext %0) nounwind !prof !14 !section_prefix !15 {
459;; Check that an unconditional branch is only appended to a block
460;; if it would fall through to the wrong block otherwise.
461; MFS-O0-LABEL:               foo16
462; MFS-O0-X86:                 jmp
463; MFS-O0-X86-NOT:             jmp
464; MFS-O0-AARCH64:                 b       foo16.cold
465; MFS-O0-AARCH64-NOT:             b       foo16.cold
466; MFS-O0:                     .section        .text.split.foo16
467; MFS-O0-NEXT:                foo16.cold
468  %2 = call i32 @baz()
469  br i1 false, label %3, label %5, !prof !25
470
4713:                                                ; preds = %1
472  %4 = call i32 @bar()
473  unreachable
474
4755:                                                ; preds = %1
476  %6 = tail call i32 @qux()
477  ret void
478}
479
480define i32 @foo17(i1 zeroext %0, i32 %a, i32 %b) nounwind !prof !14 !section_prefix !15 {
481;; Check that cold blocks in functions with red zones aren't split.
482; MFS-DEFAULTS-LABEL:        foo17
483; MFS-DEFAULTS-X86:          foo17.cold:
484; MFS-REDZONE-AARCH64-NOT:   foo17.cold:
485  %a.addr = alloca i32, align 4
486  %b.addr = alloca i32, align 4
487  %x = alloca i32, align 4
488
489  br i1 %0, label %2, label %3, !prof !17
490
4912:                                                ; preds = %1
492  store i32 %a, ptr %a.addr, align 4
493  store i32 %b, ptr %b.addr, align 4
494  br label %4
495
4963:                                                ; preds = %1
497  store i32 %a, ptr %b.addr, align 4
498  store i32 %b, ptr %a.addr, align 4
499  br label %4
500
5014:                                                ; preds = %3, %2
502  %tmp = load i32, ptr %a.addr, align 4
503  %tmp1 = load i32, ptr %b.addr, align 4
504  %add = add nsw i32 %tmp, %tmp1
505  store i32 %add, ptr %x, align 4
506  %tmp2 = load i32, ptr %x, align 4
507  ret i32 %tmp2
508}
509
510define i32 @foo18(i32 %in) !prof !14 !section_prefix !15 {
511;; Check that a cold block targeted by a jump table is not split
512;; on AArch64.
513; MFS-DEFAULTS-LABEL:        foo18
514; MFS-DEFAULTS:              .section        .text.split.foo18
515; MFS-DEFAULTS-NEXT:         foo18.cold:
516; MFS-DEFAULTS-SAME:           %common.ret
517; MFS-DEFAULTS-X86-DAG:        jmp     qux
518; MFS-DEFAULTS-X86-DAG:        jmp     bam
519; MFS-DEFAULTS-AARCH64-NOT:    b       bar
520; MFS-DEFAULTS-AARCH64-NOT:    b       baz
521; MFS-DEFAULTS-AARCH64-NOT:    b       qux
522; MFS-DEFAULTS-AARCH64-NOT:    b       bam
523
524  switch i32 %in, label %common.ret [
525    i32 0, label %hot1
526    i32 1, label %hot2
527    i32 2, label %cold1
528    i32 3, label %cold2
529  ], !prof !28
530
531common.ret:                                       ; preds = %0
532  ret i32 0
533
534hot1:                                             ; preds = %0
535  %1 = tail call i32 @bar()
536  ret i32 %1
537
538hot2:                                             ; preds = %0
539  %2 = tail call i32 @baz()
540  ret i32 %2
541
542cold1:                                            ; preds = %0
543  %3 = tail call i32 @bam()
544  ret i32 %3
545
546cold2:                                            ; preds = %0
547  %4 = tail call i32 @qux()
548  ret i32 %4
549}
550
551define i32 @foo19(i32 %in) !prof !14 !section_prefix !15 {
552;; Check that a cold block that contains a jump table dispatch is
553;; not split on AArch64.
554; MFS-DEFAULTS-LABEL:        foo19
555; MFS-DEFAULTS:              .section        .text.split.foo19
556; MFS-DEFAULTS-NEXT:         foo19.cold:
557; MFS-DEFAULTS-X86:            .LJTI17_0
558; MFS-DEFAULTS-AARCH64-NOT:    .LJTI17_0
559; MFS-DEFAULTS:              .section        .rodata
560; MFS-DEFAULTS:                .LJTI17_0
561  %cmp = icmp sgt i32 %in, 3
562  br i1 %cmp, label %hot, label %cold_switch, !prof !17
563
564hot:                                              ; preds = %0
565ret i32 1
566
567cold_switch:                                      ; preds = %0
568  switch i32 %in, label %common.ret [
569    i32 0, label %hot1
570    i32 1, label %hot2
571    i32 2, label %cold1
572    i32 3, label %cold2
573  ], !prof !28
574
575common.ret:                                       ; preds = %0
576  ret i32 0
577
578hot1:                                             ; preds = %0
579  %1 = tail call i32 @bar()
580  ret i32 %1
581
582hot2:                                             ; preds = %0
583  %2 = tail call i32 @baz()
584  ret i32 %2
585
586cold1:                                            ; preds = %0
587  %3 = tail call i32 @bam()
588  ret i32 %3
589
590cold2:                                            ; preds = %0
591  %4 = tail call i32 @qux()
592  ret i32 %4
593}
594
595define void @foo20(i1 zeroext %0) !prof !14 !section_prefix !15 {
596;; Check that blocks containing or targeted by asm goto aren't split.
597; MFS-DEFAULTS-LABEL:        foo20
598; MFS-DEFAULTS-AARCH64-NOT:  foo20.cold:
599; MFS-DEFAULTS-X86:          .section        .text.split.foo20
600; MFS-DEFAULTS-X86:          foo20.cold:
601; MFS-DEFAULTS-X86-DAG:      # %cold_asm
602; MFS-DEFAULTS-X86-DAG:      # %cold_asm_target
603
604  br i1 %0, label %hot, label %cold_asm, !prof !17
605
606hot:
607  %2 = call i32 @bar()
608  ret void
609
610cold_asm:
611    callbr void asm sideeffect "nop", "!i"() #3
612          to label %asm.fallthrough [label %cold_asm_target]
613
614asm.fallthrough:
615    br label %cold_asm_target
616
617cold_asm_target:
618  %3 = call i32 @baz()
619  ret void
620}
621
622define void @foo21(i1 zeroext %0) {
623;; Check that a function with basic-block-sections profile (but no pgo profile)
624;; is properly split when the profile is used along with mfs.
625; MFS-BBSECTIONS:            .section   .text.hot.foo21
626; MFS-NOBBSECTIONS-NOT:      .section   .text.hot.foo21
627; MFS-BBSECTIONS-LABEL:      foo21:
628; MFS-NOBBSECTIONS-NOT:      foo21.cold:
629; MFS-BBSECTIONS:            .section	.text.split.foo21
630; MFS-BBSECTIONS:            foo21.cold
631  %2 = alloca i8, align 1
632  %3 = zext i1 %0 to i8
633  store i8 %3, ptr %2, align 1
634  %4 = load i8, ptr %2, align 1
635  %5 = trunc i8 %4 to i1
636  br i1 %5, label %6, label %8
637
6386:                                                ; preds = %1
639  %7 = call i32 @bar()
640  br label %10
641
6428:                                                ; preds = %1
643  %9 = call i32 @baz()
644  br label %10
645
64610:                                               ; preds = %8, %6
647  ret void
648}
649
650define void @foo22(i1 zeroext %0) nounwind !prof !14 !section_prefix !15 {
651;; Check that when a function has both basic-block-section and pgo profiles
652;; only the basic-block-section profile is used for splitting.
653
654;; Check that we create two hot sections with -basic-block-sections.
655; MFS-BBSECTIONS:             .section        .text.hot.foo22
656; MFS-BBSECTIONS-LABEL:       foo22:
657; MFS-BBSECTIONS:             callq  bar
658; MFS-BBSECTIONS:             .section        .text.hot.foo22
659; MFS-BBSECTIONS-NEXT:        foo22.__part.1:
660; MFS-BBSECTIONS:             callq  baz
661; MFS-BBSECTIONS-NOT:         .section        .text.split.foo22
662  br i1 %0, label %2, label %4, !prof !17
663
6642:                                                ; preds = %1
665  %3 = call i32 @bar()
666  br label %6
667
6684:                                                ; preds = %1
669  %5 = call i32 @baz()
670  br label %6
671
6726:                                                ; preds = %4, %2
673  %7 = tail call i32 @qux()
674  ret void
675}
676
677declare i32 @bar()
678declare i32 @baz()
679declare i32 @bam()
680declare i32 @qux()
681declare void @_Z1fv()
682declare i32 @__gxx_personality_v0(...)
683
684@_ZTIi = external constant ptr
685
686!llvm.module.flags = !{!0}
687!0 = !{i32 1, !"ProfileSummary", !1}
688!1 = !{!2, !3, !4, !5, !6, !7, !8, !9}
689!2 = !{!"ProfileFormat", !"InstrProf"}
690!3 = !{!"TotalCount", i64 10000}
691!4 = !{!"MaxCount", i64 10}
692!5 = !{!"MaxInternalCount", i64 1}
693!6 = !{!"MaxFunctionCount", i64 1000}
694!7 = !{!"NumCounts", i64 3}
695!8 = !{!"NumFunctions", i64 5}
696!9 = !{!"DetailedSummary", !10}
697!10 = !{!11, !12, !13}
698!11 = !{i32 10000, i64 100, i32 1}
699!12 = !{i32 999900, i64 100, i32 1}
700!13 = !{i32 999999, i64 1, i32 2}
701!14 = !{!"function_entry_count", i64 7000}
702!15 = !{!"function_section_prefix", !"hot"}
703!16 = !{!"function_section_prefix", !"unlikely"}
704!17 = !{!"branch_weights", i32 7000, i32 0}
705!18 = !{!"branch_weights", i32 3000, i32 4000}
706!19 = !{!"branch_weights", i32 1000, i32 6000}
707!20 = !{!"function_entry_count", i64 10000}
708!21 = !{!"branch_weights", i32 6000, i32 4000}
709!22 = !{!"branch_weights", i32 80, i32 9920}
710!23 = !{!"function_entry_count", i64 7}
711!24 = !{!"function_entry_count", i64 10000}
712!25 = !{!"branch_weights", i32 0, i32 7000}
713!26 = !{!"branch_weights", i32 1000, i32 6000}
714!27 = !{!"function_entry_count", i64 10000}
715!28 = !{!"branch_weights", i32 0, i32 4000, i32 4000, i32 0, i32 0}
716