1; RUN: llc < %s -emulated-tls -mcpu=generic -mtriple=i386-linux-gnu -relocation-model=pic \ 2; RUN: | FileCheck -check-prefix=X86 %s 3; RUN: llc < %s -emulated-tls -mcpu=generic -mtriple=x86_64-linux-gnu -relocation-model=pic \ 4; RUN: | FileCheck -check-prefix=X64 %s 5; RUN: llc < %s -emulated-tls -mcpu=generic -mtriple=i386-linux-android -relocation-model=pic \ 6; RUN: | FileCheck -check-prefix=X86 %s 7; RUN: llc < %s -emulated-tls -mcpu=generic -mtriple=x86_64-linux-android -relocation-model=pic \ 8; RUN: | FileCheck -check-prefix=X64 %s 9 10; RUN: llc < %s -mcpu=generic -mtriple=i386-linux-gnu -relocation-model=pic \ 11; RUN: | FileCheck -check-prefix=NoEMU %s 12; RUN: llc < %s -mcpu=generic -mtriple=x86_64-linux-gnu -relocation-model=pic \ 13; RUN: | FileCheck -check-prefix=NoEMU %s 14; RUN: llc < %s -mcpu=generic -mtriple=i386-linux-android29 -relocation-model=pic \ 15; RUN: | FileCheck -check-prefix=NoEMU %s 16; RUN: llc < %s -mcpu=generic -mtriple=i386-linux-android -relocation-model=pic \ 17; RUN: | FileCheck -check-prefix=X86 %s 18; RUN: llc < %s -mcpu=generic -mtriple=x86_64-linux-android -relocation-model=pic \ 19; RUN: | FileCheck -check-prefix=X64 %s 20 21; NoEMU-NOT: __emutls 22 23; Use my_emutls_get_address like __emutls_get_address. 24@my_emutls_v_xyz = external global ptr, align 4 25declare ptr @my_emutls_get_address(ptr) 26 27define dso_local i32 @my_get_xyz() { 28; X86-LABEL: my_get_xyz: 29; X86: movl my_emutls_v_xyz@GOT(%ebx), %eax 30; X86-NEXT: movl %eax, (%esp) 31; X86-NEXT: calll my_emutls_get_address@PLT 32; X86-NEXT: movl (%eax), %eax 33; X86-NEXT: addl $8, %esp 34; X86-NEXT: .cfi_def_cfa_offset 8 35; X86-NEXT: popl %ebx 36; X86-NEXT: .cfi_def_cfa_offset 4 37; X86-NEXT: retl 38; X64-LABEL: my_get_xyz: 39; X64: movq my_emutls_v_xyz@GOTPCREL(%rip), %rdi 40; X64-NEXT: callq my_emutls_get_address@PLT 41; X64-NEXT: movl (%rax), %eax 42; X64-NEXT: popq %rcx 43; X64-NEXT: .cfi_def_cfa_offset 8 44; X64-NEXT: retq 45 46entry: 47 %call = call ptr @my_emutls_get_address(ptr @my_emutls_v_xyz) 48 %0 = load i32, ptr %call, align 4 49 ret i32 %0 50} 51 52@i = dso_local thread_local global i32 15 53@i2 = external thread_local global i32 54 55define dso_local i32 @f1() { 56; X86-LABEL: f1: 57; X86: leal __emutls_v.i@GOTOFF(%ebx), %eax 58; X86-NEXT: movl %eax, (%esp) 59; X86-NEXT: calll __emutls_get_address@PLT 60; X86-NEXT: movl (%eax), %eax 61; X86-NEXT: addl $8, %esp 62; X86-NEXT: .cfi_def_cfa_offset 8 63; X86-NEXT: popl %ebx 64; X86-NEXT: .cfi_def_cfa_offset 4 65; X86-NEXT: retl 66; X64-LABEL: f1: 67; X64: leaq __emutls_v.i(%rip), %rdi 68; X64-NEXT: callq __emutls_get_address@PLT 69; X64-NEXT: movl (%rax), %eax 70; X64-NEXT: popq %rcx 71; X64-NEXT: .cfi_def_cfa_offset 8 72; X64-NEXT: retq 73 74entry: 75 %tmp1 = load i32, ptr @i 76 ret i32 %tmp1 77} 78 79define dso_local ptr @f2() { 80; X86-LABEL: f2: 81; X86: leal __emutls_v.i@GOTOFF(%ebx), %eax 82; X86-NEXT: movl %eax, (%esp) 83; X86-NEXT: calll __emutls_get_address@PLT 84; X64-LABEL: f2: 85; X64: leaq __emutls_v.i(%rip), %rdi 86; X64-NEXT: callq __emutls_get_address@PLT 87 88entry: 89 ret ptr @i 90} 91 92define dso_local i32 @f3() { 93; X86-LABEL: f3: 94; X86: movl __emutls_v.i2@GOT(%ebx), %eax 95; X86-NEXT: movl %eax, (%esp) 96; X86-NEXT: calll __emutls_get_address@PLT 97; X64-LABEL: f3: 98; X64: movq __emutls_v.i2@GOTPCREL(%rip), %rdi 99; X64-NEXT: callq __emutls_get_address@PLT 100 101entry: 102 %tmp1 = load i32, ptr @i2 103 ret i32 %tmp1 104} 105 106define dso_local ptr @f4() { 107; X86-LABEL: f4: 108; X86: movl __emutls_v.i2@GOT(%ebx), %eax 109; X86-NEXT: movl %eax, (%esp) 110; X86-NEXT: calll __emutls_get_address@PLT 111; X64-LABEL: f4: 112; X64: movq __emutls_v.i2@GOTPCREL(%rip), %rdi 113; X64-NEXT: callq __emutls_get_address@PLT 114 115entry: 116 ret ptr @i2 117} 118 119;;;;; 32-bit targets 120 121; X86: .data 122; X86-LABEL: __emutls_v.i: 123; X86-NEXT: .long 4 124; X86-NEXT: .long 4 125; X86-NEXT: .long 0 126; X86-NEXT: .long __emutls_t.i 127 128; X86: .section .rodata, 129; X86-LABEL: __emutls_t.i: 130; X86-NEXT: .long 15 131 132; X86-NOT: __emutls_v.i2 133; X86-NOT: __emutls_t.i2 134 135;;;;; 64-bit targets 136 137; X64: .data 138; X64-LABEL: __emutls_v.i: 139; X64-NEXT: .quad 4 140; X64-NEXT: .quad 4 141; X64-NEXT: .quad 0 142; X64-NEXT: .quad __emutls_t.i 143 144; X64: .section .rodata, 145; X64-LABEL: __emutls_t.i: 146; X64-NEXT: .long 15 147 148; X64-NOT: __emutls_v.i2 149; X64-NOT: __emutls_t.i2 150 151 152!llvm.module.flags = !{!0, !1} 153!0 = !{i32 1, !"PIC Level", i32 1} 154!1 = !{i32 1, !"PIE Level", i32 1} 155