1 ;; Check if basic blocks without unique sections are only placed in cold sections if it is safe
4 ;; Profile for version 0.
6 ; RUN: echo 'f _Z3asm_goto' >> %t1
7 ; RUN: echo 'c 0' >> %t1
8 ; RUN: echo 'f _Z3jump_table' >> %t1
9 ; RUN: echo 'c 0' >> %t1
10 ; RUN: echo 'f _Z3red_zone' >> %t1
11 ; RUN: echo 'c 0' >> %t1
13 ; RUN: llc < %s -mtriple=aarch64 -function-sections -basic-block-sections=%t1 -unique-basic-block-section-names -bbsections-cold-text-prefix=".text.unlikely." | FileCheck %s
14 ; RUN: llc < %s -mtriple=aarch64 -function-sections -aarch64-min-jump-table-entries=4 -basic-block-sections=%t1 -unique-basic-block-section-names -bbsections-cold-text-prefix=".text.unlikely." | FileCheck %s -check-prefix=JUMP-TABLES
15 ; RUN: llc < %s -mtriple=aarch64 -function-sections -basic-block-sections=%t1 -unique-basic-block-section-names -bbsections-cold-text-prefix=".text.unlikely." | FileCheck %s -check-prefix=RED-ZONE
17 define void @_Z3asm_goto(i1 zeroext %0, i1 zeroext %1) nounwind {
18 ;; Check that blocks containing or targeted by asm goto aren't split.
19 ; CHECK-LABEL: _Z3asm_goto
20 ; CHECK: .section .text.unlikely._Z3asm_goto,"ax",@progbits
21 ; CHECK-NEXT: _Z3asm_goto.cold:
27 br i1 %0, label %3, label %5
31 callbr void asm sideeffect "nop", "!i"() #3
32 to label %asm.fallthrough [label %5]
35 asm.fallthrough: ; preds = %3
38 5: ; preds = %2, %asm.fallthrough
40 br i1 %1, label %7, label %9
50 define i32 @_Z3jump_table(i32 %in) nounwind {
51 ;; Check that a cold block that contains a jump table dispatch or
52 ;; that is targeted by a jump table is not split.
53 ; JUMP-TABLES-LABEL: _Z3jump_table
54 ; JUMP-TABLES: .section .text.unlikely._Z3jump_table,"ax",@progbits
55 ; JUMP-TABLES-NEXT: _Z3jump_table.cold:
56 ; JUMP-TABLES-SAME: %common.ret
57 ; JUMP-TABLES-NOT: b bar
58 ; JUMP-TABLES-NOT: b baz
59 ; JUMP-TABLES-NOT: b qux
60 ; JUMP-TABLES-NOT: b bam
62 switch i32 %in, label %common.ret [
69 common.ret: ; preds = %0
73 %1 = tail call i32 @bar()
77 %2 = tail call i32 @baz()
81 %3 = tail call i32 @bam()
85 %4 = tail call i32 @qux()
89 define i32 @_Z3red_zone(i1 zeroext %0, i32 %a, i32 %b) nounwind {
90 ;; Check that cold blocks in functions with red zones aren't split.
91 ; RED-ZONE-LABEL: _Z3red_zone
92 ; MFS-REDZONE-AARCH64-NOT: _Z3red_zone.cold:
93 %a.addr = alloca i32, align 4
94 %b.addr = alloca i32, align 4
95 %x = alloca i32, align 4
97 br i1 %0, label %2, label %3
100 store i32 %a, ptr %a.addr, align 4
101 store i32 %b, ptr %b.addr, align 4
105 store i32 %a, ptr %b.addr, align 4
106 store i32 %b, ptr %a.addr, align 4
110 %tmp = load i32, ptr %a.addr, align 4
111 %tmp1 = load i32, ptr %b.addr, align 4
112 %add = add nsw i32 %tmp, %tmp1
113 store i32 %add, ptr %x, align 4
114 %tmp2 = load i32, ptr %x, align 4