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 9define i32 @f1() { 10; X32: f1: 11; X32: movl %gs:i@NTPOFF, %eax 12; X32-NEXT: ret 13; X64: f1: 14; X64: movl %fs:i@TPOFF, %eax 15; X64-NEXT: ret 16 17entry: 18 %tmp1 = load i32* @i 19 ret i32 %tmp1 20} 21 22define i32* @f2() { 23; X32: f2: 24; X32: movl %gs:0, %eax 25; X32-NEXT: leal i@NTPOFF(%eax), %eax 26; X32-NEXT: ret 27; X64: f2: 28; X64: movq %fs:0, %rax 29; X64-NEXT: leaq i@TPOFF(%rax), %rax 30; X64-NEXT: ret 31 32entry: 33 ret i32* @i 34} 35 36define i32 @f3() { 37; X32: f3: 38; X32: calll .L{{[0-9]+}}$pb 39; X32-NEXT: .L{{[0-9]+}}$pb: 40; X32-NEXT: popl %eax 41; X32-NEXT: .Ltmp{{[0-9]+}}: 42; X32-NEXT: addl $_GLOBAL_OFFSET_TABLE_+(.Ltmp{{[0-9]+}}-.L{{[0-9]+}}$pb), %eax 43; X32-NEXT: movl i2@GOTNTPOFF(%eax), %eax 44; X32-NEXT: movl %gs:(%eax), %eax 45; X32-NEXT: ret 46; X64: f3: 47; X64: movq i2@GOTTPOFF(%rip), %rax 48; X64-NEXT: movl %fs:(%rax), %eax 49; X64-NEXT: ret 50 51entry: 52 %tmp1 = load i32* @i2 53 ret i32 %tmp1 54} 55 56define i32* @f4() { 57; X32: f4: 58; X32: calll .L{{[0-9]+}}$pb 59; X32-NEXT: .L{{[0-9]+}}$pb: 60; X32-NEXT: popl %ecx 61; X32-NEXT: .Ltmp{{[0-9]+}}: 62; X32-NEXT: addl $_GLOBAL_OFFSET_TABLE_+(.Ltmp{{[0-9]+}}-.L{{[0-9]+}}$pb), %ecx 63; X32-NEXT: movl %gs:0, %eax 64; X32-NEXT: addl i2@GOTNTPOFF(%ecx), %eax 65; X32-NEXT: ret 66; X64: f4: 67; X64: movq %fs:0, %rax 68; X64-NEXT: addq i2@GOTTPOFF(%rip), %rax 69; X64-NEXT: ret 70 71entry: 72 ret i32* @i2 73} 74