1; BB cluster section test for exception handling.
2;
3; Test1: Basic blocks #1 and #3 are landing pads and must be in the same section.
4; Basic block 2 will be placed in a unique section, but #1 and #3 are placed in the special exception section.
5; The rest will be placed in a section along with the entry basic block.
6; RUN: echo '!main' > %t1
7; RUN: echo '!!1 2' >> %t1
8; RUN: llc < %s -O0 -mtriple=x86_64-pc-linux -function-sections -basic-block-sections=%t1 | FileCheck %s -check-prefix=LINUX-SECTIONS1
9;
10; Test2: Basic blocks #1, #2, and #3 go into a separate section.
11; No separate exception section will be created as #1 and #3 are already in one section.
12; The rest will be placed in a section along with the entry basic block.
13; RUN: echo '!main' > %t2
14; RUN: echo '!!1 2 3' >> %t2
15; RUN: llc < %s -O0 -mtriple=x86_64-pc-linux -function-sections -basic-block-sections=%t2 | FileCheck %s -check-prefix=LINUX-SECTIONS2
16
17@_ZTIi = external constant i8*
18
19define i32 @main() uwtable optsize ssp personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
20entry:
21  invoke void @_Z1fv() optsize
22          to label %try.cont unwind label %lpad1
23
24lpad1:
25  %0 = landingpad { i8*, i32 }
26          cleanup
27          catch i8* bitcast (i8** @_ZTIi to i8*)
28  br label %eh.resume1
29
30try.cont:
31  invoke void @_Z2fv() optsize
32          to label %try.cont unwind label %lpad2
33  ret i32 0
34
35lpad2:
36  %2 = landingpad { i8*, i32 }
37          cleanup
38          catch i8* bitcast (i8** @_ZTIi to i8*)
39  br label %eh.resume2
40
41eh.resume1:
42  resume { i8*, i32 } %0
43
44eh.resume2:
45  resume { i8*, i32 } %2
46}
47
48declare void @_Z1fv() optsize
49
50declare void @_Z2fv() optsize
51
52declare i32 @__gxx_personality_v0(...)
53
54; LINUX-SECTIONS1:		.section	.text.main,"ax",@progbits
55; LINUX-SECTIONS1-LABEL:	main:
56; LINUX-SECTIONS1-NOT: 		.section
57; LINUX-SECTIONS1-LABEL:	.LBB0_4:
58; LINUX-SECTIONS1-NOT: 		.section
59; LINUX-SECTIONS1-LABEL:	.LBB0_5:
60; LINUX-SECTIONS1-NOT: 		.section
61; LINUX-SECTIONS1-LABEL:	.LBB0_6:
62; LINUX-SECTIONS1: 		.section	.text.main,"ax",@progbits,unique,1
63; LINUX-SECTIONS1-LABEL:	main.0:
64; LINUX-SECTIONS1:		.section	.text.eh.main,"ax",@progbits
65; LINUX-SECTIONS1-LABEL: 	main.eh:
66; LINUX-SECTIONS1-NOT: 		.section
67; LINUX-SECTIONS1-LABEL:	.LBB0_3:
68; LINUX-SECTIONS1-NOT:		.section
69; LINUX-SECTIONS1:		.section	.text.main,"ax",@progbits
70; LINUX-SECTIONS1-LABEL: 	.Lfunc_end0
71
72
73; LINUX-SECTIONS2:		.section	.text.main,"ax",@progbits
74; LINUX-SECTIONS2-LABEL:	main:
75; LINUX-SECTIONS2-NOT: 		.section
76; LINUX-SECTIONS2-LABEL:	.LBB0_4:
77; LINUX-SECTIONS2-NOT: 		.section
78; LINUX-SECTIONS2-LABEL:	.LBB0_5:
79; LINUX-SECTIONS2-NOT: 		.section
80; LINUX-SECTIONS2-LABEL:	.LBB0_6:
81; LINUX-SECTIONS2: 		.section	.text.main,"ax",@progbits,unique,1
82; LINUX-SECTIONS2-LABEL: 	main.0:
83; LINUX-SECTIONS2-NOT: 		.section
84; LINUX-SECTIONS2-LABEL:	.LBB0_2:
85; LINUX-SECTIONS2-NOT: 		.section
86; LINUX-SECTIONS2-LABEL:	.LBB0_3:
87; LINUX-SECTIONS2:		.section	.text.main,"ax",@progbits
88; LINUX-SECTIONS2-LABEL: 	.Lfunc_end0
89