xref: /llvm-project/llvm/test/CodeGen/X86/fast-isel-emutls.ll (revision b71f2fcd46790dd63dd2688c208139ea26f027d4)
1; RUN: llc < %s -emulated-tls -relocation-model=pic -mtriple=i686-unknown-linux-gnu -fast-isel | FileCheck %s
2; RUN: llc < %s -relocation-model=pic -mtriple=i686-unknown-linux-gnu -fast-isel \
3; RUN: | FileCheck -check-prefix=NoEMU %s
4; RUN: llc < %s -relocation-model=pic -mtriple=i686-linux-android29 -fast-isel \
5; RUN: | FileCheck -check-prefix=NoEMU %s
6; PR3654
7
8; NoEMU-NOT: __emutls
9
10@v = thread_local global i32 0
11define i32 @f() nounwind {
12entry:
13          %t = load i32, ptr @v
14          %s = add i32 %t, 1
15          ret i32 %s
16}
17
18; CHECK-LABEL: f:
19; CHECK:      movl __emutls_v.v@GOT(%ebx), %eax
20; CHECK-NEXT: movl %eax, (%esp)
21; CHECK-NEXT: calll __emutls_get_address@PLT
22; CHECK-NEXT: movl (%eax), %eax
23
24@alias = internal alias i32, ptr @v
25define i32 @f_alias() nounwind {
26entry:
27          %t = load i32, ptr @v
28          %s = add i32 %t, 1
29          ret i32 %s
30}
31
32; CHECK-LABEL: f_alias:
33; CHECK:      movl __emutls_v.v@GOT(%ebx), %eax
34; CHECK-NEXT: movl %eax, (%esp)
35; CHECK-NEXT: calll __emutls_get_address@PLT
36; CHECK-NEXT: movl (%eax), %eax
37
38; Use my_emutls_get_address like __emutls_get_address.
39@my_emutls_v_xyz = external global ptr, align 4
40declare ptr @my_emutls_get_address(ptr)
41
42define i32 @my_get_xyz() {
43entry:
44  %call = call ptr @my_emutls_get_address(ptr @my_emutls_v_xyz)
45  %0 = load i32, ptr %call, align 4
46  ret i32 %0
47}
48
49; CHECK-LABEL: my_get_xyz:
50; CHECK:      movl my_emutls_v_xyz@GOT(%ebx), %eax
51; CHECK-NEXT: movl %eax, (%esp)
52; CHECK-NEXT: calll my_emutls_get_address@PLT
53; CHECK-NEXT: movl (%eax), %eax
54