1; RUN: llc < %s -mtriple=x86_64-pc-linux -basic-block-sections=all | FileCheck %s
2; RUN: llc < %s -mtriple=x86_64-pc-linux -function-sections -basic-block-sections=all | FileCheck %s
3; RUN: echo "!_Z3fooi" > %t.list.txt
4; RUN: echo "!!2" >> %t.list.txt
5; RUN: llc < %s -mtriple=x86_64-pc-linux -basic-block-sections=%t.list.txt | FileCheck %s --check-prefix=LIST
6; RUN: llc < %s -mtriple=x86_64-pc-linux -function-sections -basic-block-sections=%t.list.txt | FileCheck %s --check-prefix=LIST
7
8; CHECK: .section	foo_section,"ax",@progbits,unique,1
9; CHECK-LABEL: _Z3fooi:
10; CHECK: .section	foo_section,"ax",@progbits,unique,2
11; CHECK-NEXT: _Z3fooi.__part.1:
12; CHECK: .section	foo_section,"ax",@progbits,unique,3
13; CHECK-NEXT: _Z3fooi.__part.2:
14
15; LIST: .section	foo_section,"ax",@progbits,unique,1
16; LIST-LABEL: _Z3fooi:
17; LIST: .section	foo_section,"ax",@progbits,unique,2
18; LIST-NEXT: _Z3fooi.__part.0:
19; LIST-NOT: .section	foo_section,"ax",@progbits,unique,3
20
21;; Source to generate the IR:
22;; #pragma clang section text = "foo_section"
23;; int foo(int n) {
24;;   if (n < 0)
25;;     exit(-1);
26;;   return 0;
27;; }
28
29define dso_local i32 @_Z3fooi(i32 %n) local_unnamed_addr #0 {
30entry:
31  %cmp = icmp slt i32 %n, 0
32  br i1 %cmp, label %if.then, label %if.end
33
34if.then:                                          ; preds = %entry
35  tail call void @exit(i32 -1) #2
36  unreachable
37
38if.end:                                           ; preds = %entry
39  ret i32 0
40}
41
42declare dso_local void @exit(i32) local_unnamed_addr
43
44attributes #0 = {"implicit-section-name"="foo_section" }
45