xref: /llvm-project/llvm/test/CodeGen/AArch64/basic-block-sections-cold.ll (revision ea06384bf667c635f78660f0bcfaa01372735b99)
1;; Check if basic blocks that don't get unique sections are placed in cold sections.
2;; Basic block with id 1 and 2 must be in the cold section.
3;;
4;; Profile for version 0
5; RUN: echo '!_Z3bazb' > %t1
6; RUN: echo '!!0' >> %t1
7;;
8;; Profile for version 1
9; RUN: echo 'v1' > %t2
10; RUN: echo 'f _Z3bazb' >> %t2
11; RUN: echo 'c 0' >> %t2
12;;
13; RUN: llc < %s -mtriple=aarch64 -function-sections -basic-block-sections=%t1 -unique-basic-block-section-names | FileCheck %s -check-prefix=SECTIONS
14; RUN: llc < %s -mtriple=aarch64 -function-sections -basic-block-sections=%t2 -unique-basic-block-section-names | FileCheck %s -check-prefix=SECTIONS
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=SPLIT
16
17define void @_Z3bazb(i1 zeroext %0) nounwind {
18  br i1 %0, label %2, label %4
19
202:                                                ; preds = %1
21  %3 = call i32 @_Z3barv()
22  br label %6
23
244:                                                ; preds = %1
25  %5 = call i32 @_Z3foov()
26  br label %6
27
286:                                                ; preds = %2, %4
29  ret void
30}
31
32declare i32 @_Z3barv() #1
33
34declare i32 @_Z3foov() #1
35
36; SECTIONS: .section        .text.hot._Z3bazb,"ax",@progbits
37; SECTIONS: _Z3bazb:
38; Check that the basic block with id 1 doesn't get a section.
39; SECTIONS-NOT: .section        .text{{.*}}._Z3bazb.1,"ax",@progbits,unique
40; Check that a single cold section is started here and id 1 and 2 blocks are placed here.
41; SECTIONS: .section	.text.split._Z3bazb,"ax",@progbits
42; SECTIONS: _Z3bazb.cold:
43; SECTIONS-NOT: .section        .text.hot._Z3bazb._Z3bazb.2,"ax",@progbits,unique
44; SECTIONS: .LBB0_2:
45; SECTIONS: .size   _Z3bazb, .Lfunc_end{{[0-9]}}-_Z3bazb
46
47; SPLIT:      .section	.text.unlikely._Z3bazb,"ax",@progbits
48; SPLIT-NEXT: _Z3bazb.cold:
49; SPLIT-NEXT:   bl _Z3barv
50; SPLIT:      .LBB0_2:
51; SPLIT:      .LBB_END0_2:
52