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 8 9; RUN: llc -mtriple=x86_64 -data-sections=1 -unique-section-names=0 < %s | FileCheck %s --check-prefix=NOUNIQUE 10 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" 15 16; CHECK: .section .text.fa,"axR",@progbits{{$}} 17; OLDGAS-NOT: .section .text 18; NOUNIQUE: .section .text,"axR",@progbits,unique,1 19define dso_local void @fa() { 20entry: 21 ret void 22} 23 24; CHECK: .section .text.fb,"axR",@progbits{{$}} 25; NOUNIQUE: .section .text,"axR",@progbits,unique,2 26define internal void @fb() { 27entry: 28 ret void 29} 30 31;; Explicit section. 32; CHECK: .section ccc,"axR",@progbits,unique,1 33; OLDGAS: .section ccc,"ax",@progbits,unique,1 34; NOUNIQUE: .section ccc,"axR",@progbits,unique,3 35define dso_local void @fc() section "ccc" { 36entry: 37 ret void 38} 39 40; CHECK: .section .bss.ga,"awR",@nobits{{$}} 41; OLDGAS: .bss{{$}} 42; NOUNIQUE: .section .bss,"awR",@nobits,unique,4 43@ga = global i32 0 44 45; CHECK: .section .data.gb,"awR",@progbits{{$}} 46; OLDGAS: .data{{$}} 47; NOUNIQUE: .section .data,"awR",@progbits,unique,5 48@gb = internal global i32 2 49 50; CHECK: .section .rodata.gc,"aR",@progbits{{$}} 51; OLDGAS: .section .rodata,"a",@progbits{{$}} 52; NOUNIQUE: .section .rodata,"aR",@progbits,unique,6 53@gc = constant i32 3 54 55;; Explicit section. 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" 60 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 66 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" 72 73@aa = alias i32, ptr @gf 74@ab = internal alias i32, ptr @gf 75 76!0 = !{ptr @gc} 77