summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorHans Wennborg <hans@hanshq.net>2012-06-23 11:37:03 +0000
committerHans Wennborg <hans@hanshq.net>2012-06-23 11:37:03 +0000
commitce718ff9f42c7da092eaa01dd0242e8d5ba84713 (patch)
treed3c6b996686af3fc9f47f7b5407c773a86a4f653 /test
parent47cbc4e0ee6098b7be3c60108000a979f1809949 (diff)
downloadllvm-ce718ff9f42c7da092eaa01dd0242e8d5ba84713.tar.gz
llvm-ce718ff9f42c7da092eaa01dd0242e8d5ba84713.tar.bz2
llvm-ce718ff9f42c7da092eaa01dd0242e8d5ba84713.tar.xz
Extend the IL for selecting TLS models (PR9788)
This allows the user/front-end to specify a model that is better than what LLVM would choose by default. For example, a variable might be declared as @x = thread_local(initialexec) global i32 42 if it will not be used in a shared library that is dlopen'ed. If the specified model isn't supported by the target, or if LLVM can make a better choice, a different model may be used. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159077 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/Assembler/tls-models.ll11
-rw-r--r--test/CodeGen/ARM/tls-models.ll117
-rw-r--r--test/CodeGen/Mips/tls-models.ll113
-rw-r--r--test/CodeGen/X86/tls-models.ll166
4 files changed, 407 insertions, 0 deletions
diff --git a/test/Assembler/tls-models.ll b/test/Assembler/tls-models.ll
new file mode 100644
index 0000000000..42f24962ae
--- /dev/null
+++ b/test/Assembler/tls-models.ll
@@ -0,0 +1,11 @@
+; RUN: llvm-as < %s | llvm-dis | llvm-as | llvm-dis | FileCheck %s
+
+; CHECK: @a = thread_local global i32 0
+; CHECK: @b = thread_local(localdynamic) global i32 0
+; CHECK: @c = thread_local(initialexec) global i32 0
+; CHECK: @d = thread_local(localexec) global i32 0
+
+@a = thread_local global i32 0
+@b = thread_local(localdynamic) global i32 0
+@c = thread_local(initialexec) global i32 0
+@d = thread_local(localexec) global i32 0
diff --git a/test/CodeGen/ARM/tls-models.ll b/test/CodeGen/ARM/tls-models.ll
new file mode 100644
index 0000000000..a5f3c9005a
--- /dev/null
+++ b/test/CodeGen/ARM/tls-models.ll
@@ -0,0 +1,117 @@
+; RUN: llc -march=arm -mtriple=arm-linux-gnueabi < %s | FileCheck -check-prefix=CHECK-NONPIC %s
+; RUN: llc -march=arm -mtriple=arm-linux-gnueabi -relocation-model=pic < %s | FileCheck -check-prefix=CHECK-PIC %s
+
+
+@external_gd = external thread_local global i32
+@internal_gd = internal thread_local global i32 42
+
+@external_ld = external thread_local(localdynamic) global i32
+@internal_ld = internal thread_local(localdynamic) global i32 42
+
+@external_ie = external thread_local(initialexec) global i32
+@internal_ie = internal thread_local(initialexec) global i32 42
+
+@external_le = external thread_local(localexec) global i32
+@internal_le = internal thread_local(localexec) global i32 42
+
+; ----- no model specified -----
+
+define i32* @f1() {
+entry:
+ ret i32* @external_gd
+
+ ; Non-PIC code can use initial-exec, PIC code has to use general dynamic.
+ ; CHECK-NONPIC: f1:
+ ; CHECK-NONPIC: external_gd(gottpoff)
+ ; CHECK-PIC: f1:
+ ; CHECK-PIC: external_gd(tlsgd)
+}
+
+define i32* @f2() {
+entry:
+ ret i32* @internal_gd
+
+ ; Non-PIC code can use local exec, PIC code can use local dynamic,
+ ; but that is not implemented, so falls back to general dynamic.
+ ; CHECK-NONPIC: f2:
+ ; CHECK-NONPIC: internal_gd(tpoff)
+ ; CHECK-PIC: f2:
+ ; CHECK-PIC: internal_gd(tlsgd)
+}
+
+
+; ----- localdynamic specified -----
+
+define i32* @f3() {
+entry:
+ ret i32* @external_ld
+
+ ; Non-PIC code can use initial exec, PIC should use local dynamic,
+ ; but that is not implemented, so falls back to general dynamic.
+ ; CHECK-NONPIC: f3:
+ ; CHECK-NONPIC: external_ld(gottpoff)
+ ; CHECK-PIC: f3:
+ ; CHECK-PIC: external_ld(tlsgd)
+}
+
+define i32* @f4() {
+entry:
+ ret i32* @internal_ld
+
+ ; Non-PIC code can use local exec, PIC code can use local dynamic,
+ ; but that is not implemented, so it falls back to general dynamic.
+ ; CHECK-NONPIC: f4:
+ ; CHECK-NONPIC: internal_ld(tpoff)
+ ; CHECK-PIC: f4:
+ ; CHECK-PIC: internal_ld(tlsgd)
+}
+
+
+; ----- initialexec specified -----
+
+define i32* @f5() {
+entry:
+ ret i32* @external_ie
+
+ ; Non-PIC and PIC code will use initial exec as specified.
+ ; CHECK-NONPIC: f5:
+ ; CHECK-NONPIC: external_ie(gottpoff)
+ ; CHECK-PIC: f5:
+ ; CHECK-PIC: external_ie(gottpoff)
+}
+
+define i32* @f6() {
+entry:
+ ret i32* @internal_ie
+
+ ; Non-PIC code can use local exec, PIC code use initial exec as specified.
+ ; CHECK-NONPIC: f6:
+ ; CHECK-NONPIC: internal_ie(tpoff)
+ ; CHECK-PIC: f6:
+ ; CHECK-PIC: internal_ie(gottpoff)
+}
+
+
+; ----- localexec specified -----
+
+define i32* @f7() {
+entry:
+ ret i32* @external_le
+
+ ; Non-PIC and PIC code will use local exec as specified.
+ ; CHECK-NONPIC: f7:
+ ; CHECK-NONPIC: external_le(tpoff)
+ ; CHECK-PIC: f7:
+ ; CHECK-PIC: external_le(tpoff)
+}
+
+define i32* @f8() {
+entry:
+ ret i32* @internal_le
+
+ ; Non-PIC and PIC code will use local exec as specified.
+ ; CHECK-NONPIC: f8:
+ ; CHECK-NONPIC: internal_le(tpoff)
+ ; CHECK-PIC: f8:
+ ; CHECK-PIC: internal_le(tpoff)
+}
diff --git a/test/CodeGen/Mips/tls-models.ll b/test/CodeGen/Mips/tls-models.ll
new file mode 100644
index 0000000000..8f5789ec79
--- /dev/null
+++ b/test/CodeGen/Mips/tls-models.ll
@@ -0,0 +1,113 @@
+; RUN: llc -march=mipsel < %s | FileCheck -check-prefix=CHECK-PIC %s
+; RUN: llc -march=mipsel -relocation-model=static < %s | FileCheck -check-prefix=CHECK-NONPIC %s
+
+@external_gd = external thread_local global i32
+@internal_gd = internal thread_local global i32 42
+
+@external_ld = external thread_local(localdynamic) global i32
+@internal_ld = internal thread_local(localdynamic) global i32 42
+
+@external_ie = external thread_local(initialexec) global i32
+@internal_ie = internal thread_local(initialexec) global i32 42
+
+@external_le = external thread_local(localexec) global i32
+@internal_le = internal thread_local(localexec) global i32 42
+
+; ----- no model specified -----
+
+define i32* @f1() {
+entry:
+ ret i32* @external_gd
+
+ ; Non-PIC code can use initial-exec, PIC code has to use general dynamic.
+ ; CHECK-NONPIC: f1:
+ ; CHECK-NONPIC: %gottprel
+ ; CHECK-PIC: f1:
+ ; CHECK-PIC: %tlsgd
+}
+
+define i32* @f2() {
+entry:
+ ret i32* @internal_gd
+
+ ; Non-PIC code can use local exec, PIC code can use local dynamic.
+ ; CHECK-NONPIC: f2:
+ ; CHECK-NONPIC: %tprel_hi
+ ; CHECK-PIC: f2:
+ ; CHECK-PIC: %tlsldm
+}
+
+
+; ----- localdynamic specified -----
+
+define i32* @f3() {
+entry:
+ ret i32* @external_ld
+
+ ; Non-PIC code can use initial exec, PIC should use local dynamic.
+ ; CHECK-NONPIC: f3:
+ ; CHECK-NONPIC: %gottprel
+ ; CHECK-PIC: f3:
+ ; CHECK-PIC: %tlsldm
+}
+
+define i32* @f4() {
+entry:
+ ret i32* @internal_ld
+
+ ; Non-PIC code can use local exec, PIC code can use local dynamic.
+ ; CHECK-NONPIC: f4:
+ ; CHECK-NONPIC: %tprel_hi
+ ; CHECK-PIC: f4:
+ ; CHECK-PIC: %tlsldm
+}
+
+
+; ----- initialexec specified -----
+
+define i32* @f5() {
+entry:
+ ret i32* @external_ie
+
+ ; Non-PIC and PIC code will use initial exec as specified.
+ ; CHECK-NONPIC: f5:
+ ; CHECK-NONPIC: %gottprel
+ ; CHECK-PIC: f5:
+ ; CHECK-PIC: %gottprel
+}
+
+define i32* @f6() {
+entry:
+ ret i32* @internal_ie
+
+ ; Non-PIC code can use local exec, PIC code use initial exec as specified.
+ ; CHECK-NONPIC: f6:
+ ; CHECK-NONPIC: %tprel_hi
+ ; CHECK-PIC: f6:
+ ; CHECK-PIC: %gottprel
+}
+
+
+; ----- localexec specified -----
+
+define i32* @f7() {
+entry:
+ ret i32* @external_le
+
+ ; Non-PIC and PIC code will use local exec as specified.
+ ; CHECK-NONPIC: f7:
+ ; CHECK-NONPIC: %tprel_hi
+ ; CHECK-PIC: f7:
+ ; CHECK-PIC: %tprel_hi
+}
+
+define i32* @f8() {
+entry:
+ ret i32* @internal_le
+
+ ; Non-PIC and PIC code will use local exec as specified.
+ ; CHECK-NONPIC: f8:
+ ; CHECK-NONPIC: %tprel_hi
+ ; CHECK-PIC: f8:
+ ; CHECK-PIC: %tprel_hi
+}
diff --git a/test/CodeGen/X86/tls-models.ll b/test/CodeGen/X86/tls-models.ll
new file mode 100644
index 0000000000..7c527e210a
--- /dev/null
+++ b/test/CodeGen/X86/tls-models.ll
@@ -0,0 +1,166 @@
+; RUN: llc < %s -march=x86-64 -mtriple=x86_64-linux-gnu | FileCheck -check-prefix=X64 %s
+; RUN: llc < %s -march=x86-64 -mtriple=x86_64-linux-gnu -relocation-model=pic | FileCheck -check-prefix=X64_PIC %s
+; RUN: llc < %s -march=x86 -mtriple=i386-linux-gnu | FileCheck -check-prefix=X32 %s
+; RUN: llc < %s -march=x86 -mtriple=i386-linux-gnu -relocation-model=pic | FileCheck -check-prefix=X32_PIC %s
+
+; Darwin always uses the same model.
+; RUN: llc < %s -march=x86-64 -mtriple=x86_64-apple-darwin | FileCheck -check-prefix=DARWIN %s
+
+@external_gd = external thread_local global i32
+@internal_gd = internal thread_local global i32 42
+
+@external_ld = external thread_local(localdynamic) global i32
+@internal_ld = internal thread_local(localdynamic) global i32 42
+
+@external_ie = external thread_local(initialexec) global i32
+@internal_ie = internal thread_local(initialexec) global i32 42
+
+@external_le = external thread_local(localexec) global i32
+@internal_le = internal thread_local(localexec) global i32 42
+
+; ----- no model specified -----
+
+define i32* @f1() {
+entry:
+ ret i32* @external_gd
+
+ ; Non-PIC code can use initial-exec, PIC code has to use general dynamic.
+ ; X64: f1:
+ ; X64: external_gd@GOTTPOFF
+ ; X32: f1:
+ ; X32: external_gd@INDNTPOFF
+ ; X64_PIC: f1:
+ ; X64_PIC: external_gd@TLSGD
+ ; X32_PIC: f1:
+ ; X32_PIC: external_gd@TLSGD
+ ; DARWIN: f1:
+ ; DARWIN: _external_gd@TLVP
+}
+
+define i32* @f2() {
+entry:
+ ret i32* @internal_gd
+
+ ; Non-PIC code can use local exec, PIC code can use local dynamic.
+ ; X64: f2:
+ ; X64: internal_gd@TPOFF
+ ; X32: f2:
+ ; X32: internal_gd@NTPOFF
+ ; X64_PIC: f2:
+ ; X64_PIC: internal_gd@TLSLD
+ ; X32_PIC: f2:
+ ; X32_PIC: internal_gd@TLSLDM
+ ; DARWIN: f2:
+ ; DARWIN: _internal_gd@TLVP
+}
+
+
+; ----- localdynamic specified -----
+
+define i32* @f3() {
+entry:
+ ret i32* @external_ld
+
+ ; Non-PIC code can use initial exec, PIC code use local dynamic as specified.
+ ; X64: f3:
+ ; X64: external_ld@GOTTPOFF
+ ; X32: f3:
+ ; X32: external_ld@INDNTPOFF
+ ; X64_PIC: f3:
+ ; X64_PIC: external_ld@TLSLD
+ ; X32_PIC: f3:
+ ; X32_PIC: external_ld@TLSLDM
+ ; DARWIN: f3:
+ ; DARWIN: _external_ld@TLVP
+}
+
+define i32* @f4() {
+entry:
+ ret i32* @internal_ld
+
+ ; Non-PIC code can use local exec, PIC code can use local dynamic.
+ ; X64: f4:
+ ; X64: internal_ld@TPOFF
+ ; X32: f4:
+ ; X32: internal_ld@NTPOFF
+ ; X64_PIC: f4:
+ ; X64_PIC: internal_ld@TLSLD
+ ; X32_PIC: f4:
+ ; X32_PIC: internal_ld@TLSLDM
+ ; DARWIN: f4:
+ ; DARWIN: _internal_ld@TLVP
+}
+
+
+; ----- initialexec specified -----
+
+define i32* @f5() {
+entry:
+ ret i32* @external_ie
+
+ ; Non-PIC and PIC code will use initial exec as specified.
+ ; X64: f5:
+ ; X64: external_ie@GOTTPOFF
+ ; X32: f5:
+ ; X32: external_ie@INDNTPOFF
+ ; X64_PIC: f5:
+ ; X64_PIC: external_ie@GOTTPOFF
+ ; X32_PIC: f5:
+ ; X32_PIC: external_ie@GOTNTPOFF
+ ; DARWIN: f5:
+ ; DARWIN: _external_ie@TLVP
+}
+
+define i32* @f6() {
+entry:
+ ret i32* @internal_ie
+
+ ; Non-PIC code can use local exec, PIC code use initial exec as specified.
+ ; X64: f6:
+ ; X64: internal_ie@TPOFF
+ ; X32: f6:
+ ; X32: internal_ie@NTPOFF
+ ; X64_PIC: f6:
+ ; X64_PIC: internal_ie@GOTTPOFF
+ ; X32_PIC: f6:
+ ; X32_PIC: internal_ie@GOTNTPOFF
+ ; DARWIN: f6:
+ ; DARWIN: _internal_ie@TLVP
+}
+
+
+; ----- localexec specified -----
+
+define i32* @f7() {
+entry:
+ ret i32* @external_le
+
+ ; Non-PIC and PIC code will use local exec as specified.
+ ; X64: f7:
+ ; X64: external_le@TPOFF
+ ; X32: f7:
+ ; X32: external_le@NTPOFF
+ ; X64_PIC: f7:
+ ; X64_PIC: external_le@TPOFF
+ ; X32_PIC: f7:
+ ; X32_PIC: external_le@NTPOFF
+ ; DARWIN: f7:
+ ; DARWIN: _external_le@TLVP
+}
+
+define i32* @f8() {
+entry:
+ ret i32* @internal_le
+
+ ; Non-PIC and PIC code will use local exec as specified.
+ ; X64: f8:
+ ; X64: internal_le@TPOFF
+ ; X32: f8:
+ ; X32: internal_le@NTPOFF
+ ; X64_PIC: f8:
+ ; X64_PIC: internal_le@TPOFF
+ ; X32_PIC: f8:
+ ; X32_PIC: internal_le@NTPOFF
+ ; DARWIN: f8:
+ ; DARWIN: _internal_le@TLVP
+}