summaryrefslogtreecommitdiffstats
path: root/llvm/test
diff options
context:
space:
mode:
authorEvgeniy Stepanov <eugeni.stepanov@gmail.com>2017-03-17 22:17:24 +0000
committerEvgeniy Stepanov <eugeni.stepanov@gmail.com>2017-03-17 22:17:24 +0000
commit51c962f72e9569d54dc9c853abf99e2c34fc41cf (patch)
treed0dd2501c4b1c20925959248743eb309e431d5ae /llvm/test
parent46ddab38102b79a8e477a29e68e9441313bc1f86 (diff)
downloadbcm5719-llvm-51c962f72e9569d54dc9c853abf99e2c34fc41cf.tar.gz
bcm5719-llvm-51c962f72e9569d54dc9c853abf99e2c34fc41cf.zip
Add !associated metadata.
This is an ELF-specific thing that adds SHF_LINK_ORDER to the global's section pointing to the metadata argument's section. The effect of that is a reverse dependency between sections for the linker GC. !associated does not change the behavior of global-dce. The global may also need to be added to llvm.compiler.used. Since SHF_LINK_ORDER is per-section, !associated effectively enables fdata-sections for the affected globals, the same as comdats do. Differential Revision: https://reviews.llvm.org/D29104 llvm-svn: 298157
Diffstat (limited to 'llvm/test')
-rw-r--r--llvm/test/CodeGen/X86/elf-associated.ll39
-rw-r--r--llvm/test/ThinLTO/X86/lazyload_metadata.ll6
2 files changed, 42 insertions, 3 deletions
diff --git a/llvm/test/CodeGen/X86/elf-associated.ll b/llvm/test/CodeGen/X86/elf-associated.ll
new file mode 100644
index 00000000000..20baa845277
--- /dev/null
+++ b/llvm/test/CodeGen/X86/elf-associated.ll
@@ -0,0 +1,39 @@
+; RUN: llc -data-sections=1 -mtriple x86_64-pc-linux-gnu < %s | FileCheck %s
+; RUN: llc -data-sections=0 -mtriple x86_64-pc-linux-gnu < %s | FileCheck %s
+
+@a = global i32 1
+@b = global i32 2, !associated !0
+!0 = !{i32* @a}
+; CHECK-DAG: .section .data.b,"awm",@progbits,a
+
+; Loop is OK. Also, normally -data-sections=0 would place @c and @d in the same section. !associated prevents that.
+@c = global i32 2, !associated !2
+@d = global i32 2, !associated !1
+!1 = !{i32* @c}
+!2 = !{i32* @d}
+; CHECK-DAG: .section .data.c,"awm",@progbits,d
+; CHECK-DAG: .section .data.d,"awm",@progbits,c
+
+; BSS is OK.
+@e = global i32 0
+@f = global i32 0, !associated !3
+@g = global i32 1, !associated !3
+!3 = !{i32* @e}
+; CHECK-DAG: .section .bss.f,"awm",@nobits,e
+; CHECK-DAG: .section .data.g,"awm",@progbits,e
+
+; Explicit sections.
+@h = global i32 1, section "aaa"
+@i = global i32 1, section "bbb", !associated !4
+@j = global i32 1, section "bbb", !associated !4
+@k = global i32 1, !associated !4
+!4 = !{i32* @h}
+; CHECK-DAG: .section aaa,"aw",@progbits
+; CHECK-DAG: .section bbb,"awm",@progbits,h,unique,1
+; CHECK-DAG: .section bbb,"awm",@progbits,h,unique,2
+; CHECK-DAG: .section .data.k,"awm",@progbits,h
+
+; Non-GlobalObject metadata.
+@l = global i32 1, section "ccc", !associated !5
+!5 = !{i32* null}
+; CHECK-DAG: .section ccc,"aw",@progbits
diff --git a/llvm/test/ThinLTO/X86/lazyload_metadata.ll b/llvm/test/ThinLTO/X86/lazyload_metadata.ll
index bddabcdf9e7..f5b6b96ebf0 100644
--- a/llvm/test/ThinLTO/X86/lazyload_metadata.ll
+++ b/llvm/test/ThinLTO/X86/lazyload_metadata.ll
@@ -10,13 +10,13 @@
; RUN: llvm-lto -thinlto-action=import %t2.bc -thinlto-index=%t3.bc \
; RUN: -o /dev/null -stats \
; RUN: 2>&1 | FileCheck %s -check-prefix=LAZY
-; LAZY: 49 bitcode-reader - Number of Metadata records loaded
+; LAZY: 51 bitcode-reader - Number of Metadata records loaded
; LAZY: 2 bitcode-reader - Number of MDStrings loaded
; RUN: llvm-lto -thinlto-action=import %t2.bc -thinlto-index=%t3.bc \
; RUN: -o /dev/null -disable-ondemand-mds-loading -stats \
; RUN: 2>&1 | FileCheck %s -check-prefix=NOTLAZY
-; NOTLAZY: 58 bitcode-reader - Number of Metadata records loaded
+; NOTLAZY: 60 bitcode-reader - Number of Metadata records loaded
; NOTLAZY: 7 bitcode-reader - Number of MDStrings loaded
@@ -55,4 +55,4 @@ declare i1 @llvm.type.test(i8* %ptr, metadata %bitset) nounwind readnone
!6 = !{!9}
!7 = !{!"7"}
!8 = !{!"8"}
-!9 = !{!6} \ No newline at end of file
+!9 = !{!6}
OpenPOWER on IntegriCloud