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
7 ; RUN: llc -mtriple=x86_64 -data-sections=1 -unique-section-names=0 < %s | FileCheck %s --check-prefix=NOUNIQUE
9 @llvm.used = appending global [10 x i8*] [
10 i8* bitcast (void ()* @fa to i8*), i8* bitcast (void ()* @fb to i8*), i8* bitcast (void ()* @fc to i8*),
11 i8* bitcast (i32* @ga to i8*), i8* bitcast (i32* @gb to i8*), i8* bitcast (i32* @gc to i8*), i8* bitcast (i32* @gd to i8*), i8* bitcast (i32* @ge to i8*),
12 i8* bitcast (i32* @aa to i8*), i8* bitcast (i32* @ab to i8*) ], section "llvm.metadata"
14 ; CHECK: .section .text.fa,"axR",@progbits{{$}}
15 ; OLDGAS-NOT: .section .text
16 ; NOUNIQUE: .section .text,"axR",@progbits,unique,1
17 define dso_local void @fa() {
22 ; CHECK: .section .text.fb,"axR",@progbits{{$}}
23 ; NOUNIQUE: .section .text,"axR",@progbits,unique,2
24 define internal void @fb() {
30 ; CHECK: .section ccc,"axR",@progbits,unique,1
31 ; OLDGAS: .section ccc,"ax",@progbits,unique,1
32 ; NOUNIQUE: .section ccc,"axR",@progbits,unique,3
33 define dso_local void @fc() section "ccc" {
38 ; CHECK: .section .bss.ga,"awR",@nobits{{$}}
40 ; NOUNIQUE: .section .bss,"awR",@nobits,unique,4
43 ; CHECK: .section .data.gb,"awR",@progbits{{$}}
45 ; NOUNIQUE: .section .data,"awR",@progbits,unique,5
46 @gb = internal global i32 2
48 ; CHECK: .section .rodata.gc,"aR",@progbits{{$}}
49 ; OLDGAS: .section .rodata,"a",@progbits{{$}}
50 ; NOUNIQUE: .section .rodata,"aR",@progbits,unique,6
54 ; CHECK: .section ddd,"awR",@progbits,unique,2
55 ; OLDGAS: .section ddd,"aw",@progbits,unique,2
56 ; NOUNIQUE: .section ddd,"awR",@progbits,unique,7
57 @gd = global i32 1, section "ddd"
59 ;; Used together with !associated.
60 ; CHECK: .section .data.ge,"awoR",@progbits,gc
61 ; OLDGAS: .section .data.ge,"awo",@progbits,gc
62 ; NOUNIQUE: .section .data,"awoR",@progbits,gc,unique,8
63 @ge = global i32 1, !associated !0
65 ;; Aliases in llvm.used are ignored.
66 ; CHECK: .section fff,"aw",@progbits{{$}}
67 ; OLDGAS: .section fff,"aw",@progbits{{$}}
68 ; NOUNIQUE: .section fff,"aw",@progbits{{$}}
69 @gf = global i32 1, section "fff"
71 @aa = alias i32, i32* @gf
72 @ab = internal alias i32, i32* @gf