1 ; RUN: llc < %s -march=x86 -mcpu=generic -mtriple=i386-linux-gnu -relocation-model=pic -enable-pie \ 2 ; RUN: | FileCheck -check-prefix=X32 %s 3 ; RUN: llc < %s -march=x86-64 -mcpu=generic -mtriple=x86_64-linux-gnu -relocation-model=pic -enable-pie \ 4 ; RUN: | FileCheck -check-prefix=X64 %s 5 6 @i = thread_local global i32 15 7 @i2 = external thread_local global i32 8 9 define i32 @f1() { 10 ; X32-LABEL: f1: 11 ; X32: movl %gs:i@NTPOFF, %eax 12 ; X32-NEXT: ret 13 ; X64-LABEL: f1: 14 ; X64: movl %fs:i@TPOFF, %eax 15 ; X64-NEXT: ret 16 17 entry: 18 %tmp1 = load i32, i32* @i 19 ret i32 %tmp1 20 } 21 22 define i32* @f2() { 23 ; X32-LABEL: f2: 24 ; X32: movl %gs:0, %eax 25 ; X32-NEXT: leal i@NTPOFF(%eax), %eax 26 ; X32-NEXT: ret 27 ; X64-LABEL: f2: 28 ; X64: movq %fs:0, %rax 29 ; X64-NEXT: leaq i@TPOFF(%rax), %rax 30 ; X64-NEXT: ret 31 32 entry: 33 ret i32* @i 34 } 35 36 define i32 @f3() { 37 ; X32-LABEL: f3: 38 ; X32: calll .L{{[0-9]+}}$pb 39 ; X32-NEXT: .Ltmp{{[0-9]+}}: 40 ; X32-NEXT: .cfi_adjust_cfa_offset 4 41 ; X32-NEXT: .L{{[0-9]+}}$pb: 42 ; X32-NEXT: popl %eax 43 ; X32-NEXT: .Ltmp{{[0-9]+}}: 44 ; X32-NEXT: .cfi_adjust_cfa_offset -4 45 ; X32-NEXT: .Ltmp{{[0-9]+}}: 46 ; X32-NEXT: addl $_GLOBAL_OFFSET_TABLE_+(.Ltmp{{[0-9]+}}-.L{{[0-9]+}}$pb), %eax 47 ; X32-NEXT: movl i2@GOTNTPOFF(%eax), %eax 48 ; X32-NEXT: movl %gs:(%eax), %eax 49 ; X32-NEXT: ret 50 ; X64-LABEL: f3: 51 ; X64: movq i2@GOTTPOFF(%rip), %rax 52 ; X64-NEXT: movl %fs:(%rax), %eax 53 ; X64-NEXT: ret 54 55 entry: 56 %tmp1 = load i32, i32* @i2 57 ret i32 %tmp1 58 } 59 60 define i32* @f4() { 61 ; X32-LABEL: f4: 62 ; X32: calll .L{{[0-9]+}}$pb 63 ; X32-NEXT: .Ltmp{{[0-9]+}}: 64 ; X32-NEXT: .cfi_adjust_cfa_offset 4 65 ; X32-NEXT: .L{{[0-9]+}}$pb: 66 ; X32-NEXT: popl %ecx 67 ; X32-NEXT: .Ltmp{{[0-9]+}}: 68 ; X32-NEXT: .cfi_adjust_cfa_offset -4 69 ; X32-NEXT: .Ltmp{{[0-9]+}}: 70 ; X32-NEXT: addl $_GLOBAL_OFFSET_TABLE_+(.Ltmp{{[0-9]+}}-.L{{[0-9]+}}$pb), %ecx 71 ; X32-NEXT: movl %gs:0, %eax 72 ; X32-NEXT: addl i2@GOTNTPOFF(%ecx), %eax 73 ; X32-NEXT: ret 74 ; X64-LABEL: f4: 75 ; X64: movq %fs:0, %rax 76 ; X64-NEXT: addq i2@GOTTPOFF(%rip), %rax 77 ; X64-NEXT: ret 78 79 entry: 80 ret i32* @i2 81 } 82