1 ; RUN: llc -mtriple aarch64-windows %s -o - | FileCheck %s
3 @tlsVar = thread_local global i32 0
4 @tlsVar8 = thread_local global i8 0
5 @tlsVar64 = thread_local global i64 0
8 %1 = load i32, i32* @tlsVar
12 define i32* @getPtr() {
16 define void @setVar(i32 %val) {
17 store i32 %val, i32* @tlsVar
21 define i8 @getVar8() {
22 %1 = load i8, i8* @tlsVar8
26 define i64 @getVar64() {
27 %1 = load i64, i64* @tlsVar64
32 ; CHECK: adrp [[TLS_INDEX_ADDR:x[0-9]+]], _tls_index
33 ; CHECK: ldr w[[TLS_INDEX:[0-9]+]], {{\[}}[[TLS_INDEX_ADDR]], _tls_index]
34 ; CHECK: ldr [[TLS_POINTER:x[0-9]+]], [x18, #88]
36 ; CHECK: ldr [[TLS:x[0-9]+]], {{\[}}[[TLS_POINTER]], x[[TLS_INDEX]], lsl #3]
37 ; CHECK: add [[TLS]], [[TLS]], :secrel_hi12:tlsVar
38 ; CHECK: ldr w0, {{\[}}[[TLS]], :secrel_lo12:tlsVar{{\]}}
41 ; CHECK: adrp [[TLS_INDEX_ADDR:x[0-9]+]], _tls_index
42 ; CHECK: ldr w[[TLS_INDEX:[0-9]+]], {{\[}}[[TLS_INDEX_ADDR]], _tls_index]
43 ; CHECK: ldr [[TLS_POINTER:x[0-9]+]], [x18, #88]
45 ; CHECK: ldr [[TLS:x[0-9]+]], {{\[}}[[TLS_POINTER]], x[[TLS_INDEX]], lsl #3]
46 ; CHECK: add [[TLS]], [[TLS]], :secrel_hi12:tlsVar
47 ; CHECK: add x0, [[TLS]], :secrel_lo12:tlsVar
50 ; CHECK: adrp [[TLS_INDEX_ADDR:x[0-9]+]], _tls_index
51 ; CHECK: ldr w[[TLS_INDEX:[0-9]+]], {{\[}}[[TLS_INDEX_ADDR]], _tls_index]
52 ; CHECK: ldr [[TLS_POINTER:x[0-9]+]], [x18, #88]
54 ; CHECK: ldr [[TLS:x[0-9]+]], {{\[}}[[TLS_POINTER]], x[[TLS_INDEX]], lsl #3]
55 ; CHECK: add [[TLS]], [[TLS]], :secrel_hi12:tlsVar
56 ; CHECK: str w0, {{\[}}[[TLS]], :secrel_lo12:tlsVar{{\]}}
58 ; CHECK-LABEL: getVar8
59 ; CHECK: add [[TLS:x[0-9]+]], [[TLS]], :secrel_hi12:tlsVar8
60 ; CHECK: ldrb w0, {{\[}}[[TLS]], :secrel_lo12:tlsVar8{{\]}}
62 ; CHECK-LABEL: getVar64
63 ; CHECK: add [[TLS:x[0-9]+]], [[TLS]], :secrel_hi12:tlsVar64
64 ; CHECK: ldr x0, {{\[}}[[TLS]], :secrel_lo12:tlsVar64{{\]}}