1 ; NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 ; RUN: llc -o - -verify-machineinstrs -O0 -global-isel -stop-after=localizer %s | FileCheck %s
3 target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
4 target triple = "arm64-apple-ios5.0.0"
6 @var1 = common global i32 0, align 4
7 @var2 = common global i32 0, align 4
8 @var3 = common global i32 0, align 4
9 @var4 = common global i32 0, align 4
11 ; This is an ll test instead of MIR because -run-pass doesn't seem to support
12 ; initializing the target TTI which we need for this test.
14 ; Some of the instructions in entry block are dead after this pass so don't
15 ; strictly need to be checked for.
18 ; CHECK-LABEL: name: foo
20 ; CHECK: successors: %bb.2(0x40000000), %bb.3(0x40000000)
21 ; CHECK: [[GV:%[0-9]+]]:gpr(p0) = G_GLOBAL_VALUE @var1
22 ; CHECK: [[C:%[0-9]+]]:gpr(s32) = G_CONSTANT i32 2
23 ; CHECK: [[GV1:%[0-9]+]]:gpr(p0) = G_GLOBAL_VALUE @var2
24 ; CHECK: [[C1:%[0-9]+]]:gpr(s32) = G_CONSTANT i32 3
25 ; CHECK: [[GV2:%[0-9]+]]:gpr(p0) = G_GLOBAL_VALUE @var3
26 ; CHECK: [[C2:%[0-9]+]]:gpr(s32) = G_CONSTANT i32 0
27 ; CHECK: [[LOAD:%[0-9]+]]:gpr(s32) = G_LOAD [[GV]](p0) :: (dereferenceable load (s32) from @var1)
28 ; CHECK: [[C3:%[0-9]+]]:gpr(s32) = G_CONSTANT i32 1
29 ; CHECK: [[ICMP:%[0-9]+]]:gpr(s32) = G_ICMP intpred(ne), [[LOAD]](s32), [[C3]]
30 ; CHECK: [[TRUNC:%[0-9]+]]:gpr(s1) = G_TRUNC [[ICMP]](s32)
31 ; CHECK: G_BRCOND [[TRUNC]](s1), %bb.3
33 ; CHECK: bb.2.if.then:
34 ; CHECK: successors: %bb.3(0x80000000)
35 ; CHECK: [[GV3:%[0-9]+]]:gpr(p0) = G_GLOBAL_VALUE @var2
36 ; CHECK: [[C4:%[0-9]+]]:gpr(s32) = G_CONSTANT i32 2
37 ; CHECK: G_STORE [[C4]](s32), [[GV3]](p0) :: (store (s32) into @var2)
38 ; CHECK: [[C5:%[0-9]+]]:gpr(s32) = G_CONSTANT i32 3
39 ; CHECK: G_STORE [[C5]](s32), [[GV]](p0) :: (store (s32) into @var1)
40 ; CHECK: [[GV4:%[0-9]+]]:gpr(p0) = G_GLOBAL_VALUE @var3
41 ; CHECK: G_STORE [[C4]](s32), [[GV4]](p0) :: (store (s32) into @var3)
42 ; CHECK: G_STORE [[C5]](s32), [[GV]](p0) :: (store (s32) into @var1)
44 ; CHECK: [[C6:%[0-9]+]]:gpr(s32) = G_CONSTANT i32 0
45 ; CHECK: $w0 = COPY [[C6]](s32)
46 ; CHECK: RET_ReallyLR implicit $w0
48 %0 = load i32, i32* @var1, align 4
49 %cmp = icmp eq i32 %0, 1
50 br i1 %cmp, label %if.then, label %if.end
53 store i32 2, i32* @var2, align 4
54 store i32 3, i32* @var1, align 4
55 store i32 2, i32* @var3, align 4
56 store i32 3, i32* @var1, align 4
63 @tls_gv = common thread_local global i32 0, align 4
65 ; This test checks that we don't try to localize TLS variables on Darwin.
66 ; If the user happens to be inside a call sequence, we could end up rematerializing
67 ; below a physreg write, clobbering it (TLS accesses on Darwin need a function call).
68 ; For now, we check we don't localize at all. We could in theory make sure that
69 ; we don't localize into the middle of a call sequence instead.
70 define i32 @darwin_tls() {
71 ; CHECK-LABEL: name: darwin_tls
73 ; CHECK: successors: %bb.2(0x40000000), %bb.3(0x40000000)
74 ; CHECK: [[GV:%[0-9]+]]:gpr(p0) = G_GLOBAL_VALUE @tls_gv
75 ; CHECK: [[GV1:%[0-9]+]]:gpr(p0) = G_GLOBAL_VALUE @var2
76 ; CHECK: [[C:%[0-9]+]]:gpr(s32) = G_CONSTANT i32 0
77 ; CHECK: [[GV2:%[0-9]+]]:gpr(p0) = G_GLOBAL_VALUE @var1
78 ; CHECK: [[LOAD:%[0-9]+]]:gpr(s32) = G_LOAD [[GV2]](p0) :: (dereferenceable load (s32) from @var1)
79 ; CHECK: [[C1:%[0-9]+]]:gpr(s32) = G_CONSTANT i32 1
80 ; CHECK: [[ICMP:%[0-9]+]]:gpr(s32) = G_ICMP intpred(ne), [[LOAD]](s32), [[C1]]
81 ; CHECK: [[TRUNC:%[0-9]+]]:gpr(s1) = G_TRUNC [[ICMP]](s32)
82 ; CHECK: G_BRCOND [[TRUNC]](s1), %bb.3
84 ; CHECK: bb.2.if.then:
85 ; CHECK: successors: %bb.3(0x80000000)
86 ; CHECK: [[LOAD1:%[0-9]+]]:gpr(s32) = G_LOAD [[GV]](p0) :: (dereferenceable load (s32) from @tls_gv)
87 ; CHECK: [[GV3:%[0-9]+]]:gpr(p0) = G_GLOBAL_VALUE @var2
88 ; CHECK: G_STORE [[LOAD1]](s32), [[GV3]](p0) :: (store (s32) into @var2)
90 ; CHECK: [[C2:%[0-9]+]]:gpr(s32) = G_CONSTANT i32 0
91 ; CHECK: $w0 = COPY [[C2]](s32)
92 ; CHECK: RET_ReallyLR implicit $w0
94 %0 = load i32, i32* @var1, align 4
95 %cmp = icmp eq i32 %0, 1
96 br i1 %cmp, label %if.then, label %if.end
99 %tls = load i32, i32* @tls_gv, align 4
100 store i32 %tls, i32* @var2, align 4