1 ;; Place a global object in the llvm.used list in a unique section with the SHF_GNU_RETAIN flag.
2 ; RUN: llc -mtriple=x86_64 < %s | FileCheck %s
3 ; RUN: llc -mtriple=x86_64 -data-sections=1 < %s | FileCheck %s
4 ; RUN: llc -mtriple=x86_64 -no-integrated-as -binutils-version=2.36 < %s | FileCheck %s
5 ; RUN: llc -mtriple=x86_64 -no-integrated-as -binutils-version=2.35 < %s | FileCheck %s --check-prefix=OLDGAS
6 ;; Solaris uses the equivalent SHF_SUNW_NODISCARD flag, also represented as "R".
7 ; RUN: llc -mtriple=x86_64-solaris < %s | FileCheck %s
9 ; RUN: llc -mtriple=x86_64 -data-sections=1 -unique-section-names=0 < %s | FileCheck %s --check-prefix=NOUNIQUE
11 @llvm.used = appending global [10 x ptr] [
12 ptr @fa, ptr @fb, ptr @fc,
13 ptr @ga, ptr @gb, ptr @gc, ptr @gd, ptr @ge,
14 ptr @aa, ptr @ab ], section "llvm.metadata"
16 ; CHECK: .section .text.fa,"axR",@progbits{{$}}
17 ; OLDGAS-NOT: .section .text
18 ; NOUNIQUE: .section .text,"axR",@progbits,unique,1
19 define dso_local void @fa() {
24 ; CHECK: .section .text.fb,"axR",@progbits{{$}}
25 ; NOUNIQUE: .section .text,"axR",@progbits,unique,2
26 define internal void @fb() {
32 ; CHECK: .section ccc,"axR",@progbits,unique,1
33 ; OLDGAS: .section ccc,"ax",@progbits,unique,1
34 ; NOUNIQUE: .section ccc,"axR",@progbits,unique,3
35 define dso_local void @fc() section "ccc" {
40 ; CHECK: .section .bss.ga,"awR",@nobits{{$}}
42 ; NOUNIQUE: .section .bss,"awR",@nobits,unique,4
45 ; CHECK: .section .data.gb,"awR",@progbits{{$}}
47 ; NOUNIQUE: .section .data,"awR",@progbits,unique,5
48 @gb = internal global i32 2
50 ; CHECK: .section .rodata.gc,"aR",@progbits{{$}}
51 ; OLDGAS: .section .rodata,"a",@progbits{{$}}
52 ; NOUNIQUE: .section .rodata,"aR",@progbits,unique,6
56 ; CHECK: .section ddd,"awR",@progbits,unique,2
57 ; OLDGAS: .section ddd,"aw",@progbits,unique,2
58 ; NOUNIQUE: .section ddd,"awR",@progbits,unique,7
59 @gd = global i32 1, section "ddd"
61 ;; Used together with !associated.
62 ; CHECK: .section .data.ge,"awoR",@progbits,gc
63 ; OLDGAS: .section .data.ge,"awo",@progbits,gc
64 ; NOUNIQUE: .section .data,"awoR",@progbits,gc,unique,8
65 @ge = global i32 1, !associated !0
67 ;; Aliases in llvm.used are ignored.
68 ; CHECK: .section fff,"aw",@progbits{{$}}
69 ; OLDGAS: .section fff,"aw",@progbits{{$}}
70 ; NOUNIQUE: .section fff,"aw",@progbits{{$}}
71 @gf = global i32 1, section "fff"
73 @aa = alias i32, ptr @gf
74 @ab = internal alias i32, ptr @gf