xref: /llvm-project/llvm/test/CodeGen/X86/basic-block-sections-cold.ll (revision 6ac71a0149cf92afac71b8b61f17f93af2731bfd)
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=x86_64 -function-sections -basic-block-sections=%t1 -unique-basic-block-section-names | FileCheck %s -check-prefix=LINUX-SECTIONS
14; RUN: llc < %s -mtriple=x86_64 -function-sections -basic-block-sections=%t2 -unique-basic-block-section-names | FileCheck %s -check-prefix=LINUX-SECTIONS
15; RUN: llc < %s -mtriple=x86_64 -function-sections -basic-block-sections=%t1 -unique-basic-block-section-names -bbsections-cold-text-prefix=".text.unlikely." | FileCheck %s -check-prefix=LINUX-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; LINUX-SECTIONS: .section        .text.hot._Z3bazb,"ax",@progbits
37; LINUX-SECTIONS: _Z3bazb:
38; Check that the basic block with id 1 doesn't get a section.
39; LINUX-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; LINUX-SECTIONS: .section	.text.split._Z3bazb,"ax",@progbits
42; LINUX-SECTIONS: _Z3bazb.cold:
43; LINUX-SECTIONS-NOT: .section        .text.hot._Z3bazb._Z3bazb.2,"ax",@progbits,unique
44; LINUX-SECTIONS: .LBB0_2:
45; LINUX-SECTIONS: .size   _Z3bazb, .Lfunc_end{{[0-9]}}-_Z3bazb
46
47; LINUX-SPLIT:      .section	.text.unlikely._Z3bazb,"ax",@progbits
48; LINUX-SPLIT-NEXT: _Z3bazb.cold:
49; LINUX-SPLIT-NEXT:   callq _Z3barv
50; LINUX-SPLIT:      .LBB0_2:
51; LINUX-SPLIT:      .LBB_END0_2:
52