1 ; RUN: llc -mtriple aarch64-windows %s -o - | FileCheck %s 2 3 @tlsVar = thread_local global i32 0 4 @tlsVar8 = thread_local global i8 0 5 @tlsVar64 = thread_local global i64 0 6 7 define i32 @getVar() { 8 %1 = load i32, i32* @tlsVar 9 ret i32 %1 10 } 11 12 define i32* @getPtr() { 13 ret i32* @tlsVar 14 } 15 16 define void @setVar(i32 %val) { 17 store i32 %val, i32* @tlsVar 18 ret void 19 } 20 21 define i8 @getVar8() { 22 %1 = load i8, i8* @tlsVar8 23 ret i8 %1 24 } 25 26 define i64 @getVar64() { 27 %1 = load i64, i64* @tlsVar64 28 ret i64 %1 29 } 30 31 ; CHECK-LABEL: getVar 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] 35 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{{\]}} 39 40 ; CHECK-LABEL: getPtr 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] 44 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 48 49 ; CHECK-LABEL: setVar 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] 53 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{{\]}} 57 58 ; CHECK-LABEL: getVar8 59 ; CHECK: add [[TLS:x[0-9]+]], [[TLS]], :secrel_hi12:tlsVar8 60 ; CHECK: ldrb w0, {{\[}}[[TLS]], :secrel_lo12:tlsVar8{{\]}} 61 62 ; CHECK-LABEL: getVar64 63 ; CHECK: add [[TLS:x[0-9]+]], [[TLS]], :secrel_hi12:tlsVar64 64 ; CHECK: ldr x0, {{\[}}[[TLS]], :secrel_lo12:tlsVar64{{\]}} 65