1 ; RUN: llc < %s -march=x86 -mtriple=i386-linux-gnu -relocation-model=pic | FileCheck -check-prefix=X32 %s 2 ; RUN: llc < %s -march=x86-64 -mtriple=x86_64-linux-gnu -relocation-model=pic | FileCheck -check-prefix=X64 %s 3 4 @i = thread_local global i32 15 5 @j = internal thread_local global i32 42 6 @k = internal thread_local global i32 42 7 8 define i32 @f1() { 9 entry: 10 %tmp1 = load i32, i32* @i 11 ret i32 %tmp1 12 } 13 14 ; X32-LABEL: f1: 15 ; X32: leal i@TLSGD(,%ebx), %eax 16 ; X32: calll ___tls_get_addr@PLT 17 18 ; X64-LABEL: f1: 19 ; X64: leaq i@TLSGD(%rip), %rdi 20 ; X64: callq __tls_get_addr@PLT 21 22 23 @i2 = external thread_local global i32 24 25 define i32* @f2() { 26 entry: 27 ret i32* @i 28 } 29 30 ; X32-LABEL: f2: 31 ; X32: leal i@TLSGD(,%ebx), %eax 32 ; X32: calll ___tls_get_addr@PLT 33 34 ; X64-LABEL: f2: 35 ; X64: leaq i@TLSGD(%rip), %rdi 36 ; X64: callq __tls_get_addr@PLT 37 38 39 40 define i32 @f3() { 41 entry: 42 %tmp1 = load i32, i32* @i ; <i32> [#uses=1] 43 ret i32 %tmp1 44 } 45 46 ; X32-LABEL: f3: 47 ; X32: leal i@TLSGD(,%ebx), %eax 48 ; X32: calll ___tls_get_addr@PLT 49 50 ; X64-LABEL: f3: 51 ; X64: leaq i@TLSGD(%rip), %rdi 52 ; X64: callq __tls_get_addr@PLT 53 54 55 define i32* @f4() nounwind { 56 entry: 57 ret i32* @i 58 } 59 60 ; X32-LABEL: f4: 61 ; X32: leal i@TLSGD(,%ebx), %eax 62 ; X32: calll ___tls_get_addr@PLT 63 64 ; X64-LABEL: f4: 65 ; X64: leaq i@TLSGD(%rip), %rdi 66 ; X64: callq __tls_get_addr@PLT 67 68 69 define i32 @f5() nounwind { 70 entry: 71 %0 = load i32, i32* @j, align 4 72 %1 = load i32, i32* @k, align 4 73 %add = add nsw i32 %0, %1 74 ret i32 %add 75 } 76 77 ; X32-LABEL: f5: 78 ; X32: leal {{[jk]}}@TLSLDM(%ebx) 79 ; X32: calll ___tls_get_addr@PLT 80 ; X32: movl {{[jk]}}@DTPOFF(%e 81 ; X32: addl {{[jk]}}@DTPOFF(%e 82 83 ; X64-LABEL: f5: 84 ; X64: leaq {{[jk]}}@TLSLD(%rip), %rdi 85 ; X64: callq __tls_get_addr@PLT 86 ; X64: movl {{[jk]}}@DTPOFF(%r 87 ; X64: addl {{[jk]}}@DTPOFF(%r 88