1 ; RUN: llc -mtriple=aarch64-unknown-linux-gnu -relocation-model=pic -verify-machineinstrs %s -o - | FileCheck %s
3 ; TLSDESC resolver calling convention does not retain the flags register.
4 ; Check that a TLS descriptor call cannot be lowered in between a cmp and the use of flags.
6 @var = thread_local global i32 zeroinitializer
7 @test = global i32 zeroinitializer
9 define i32 @test_thread_local() {
10 ; CHECK-LABEL: test_thread_local:
12 ; CHECK-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill
13 ; CHECK-NEXT: .cfi_def_cfa_offset 16
14 ; CHECK-NEXT: .cfi_offset w30, -16
15 ; CHECK-NEXT: adrp x8, :got:test
16 ; CHECK-NEXT: ldr x8, [x8, :got_lo12:test]
17 ; CHECK-NEXT: adrp x0, :tlsdesc:var
18 ; CHECK-NEXT: ldr x1, [x0, :tlsdesc_lo12:var]
19 ; CHECK-NEXT: add x0, x0, :tlsdesc_lo12:var
20 ; CHECK-NEXT: .tlsdesccall var
22 ; CHECK-NEXT: mrs x9, TPIDR_EL0
23 ; CHECK-NEXT: ldr w9, [x9, x0]
24 ; CHECK-NEXT: cmp x8, #0
25 ; CHECK-NEXT: cinc w0, w9, eq
26 ; CHECK-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload
29 %testval = load i32, ptr @test
30 %test = icmp eq ptr @test, null
31 %val = load i32, ptr @var
32 %result = zext i1 %test to i32
33 %result2 = add i32 %val, %result