1; RUN: llc < %s -mtriple=thumbv7-w64-mingw32 | FileCheck %s
2
3@var = external local_unnamed_addr global i32, align 4
4@dsolocalvar = external dso_local local_unnamed_addr global i32, align 4
5@localvar = dso_local local_unnamed_addr global i32 0, align 4
6@localcommon = common dso_local local_unnamed_addr global i32 0, align 4
7@extvar = external dllimport local_unnamed_addr global i32, align 4
8
9define dso_local i32 @getVar() {
10; CHECK-LABEL: getVar:
11; CHECK:    movw r0, :lower16:.refptr.var
12; CHECK:    movt r0, :upper16:.refptr.var
13; CHECK:    ldr  r0, [r0]
14; CHECK:    ldr  r0, [r0]
15; CHECK:    bx   lr
16entry:
17  %0 = load i32, i32* @var, align 4
18  ret i32 %0
19}
20
21define dso_local i32 @getDsoLocalVar() {
22; CHECK-LABEL: getDsoLocalVar:
23; CHECK:    movw r0, :lower16:dsolocalvar
24; CHECK:    movt r0, :upper16:dsolocalvar
25; CHECK:    ldr  r0, [r0]
26; CHECK:    bx   lr
27entry:
28  %0 = load i32, i32* @dsolocalvar, align 4
29  ret i32 %0
30}
31
32define dso_local i32 @getLocalVar() {
33; CHECK-LABEL: getLocalVar:
34; CHECK:    movw r0, :lower16:localvar
35; CHECK:    movt r0, :upper16:localvar
36; CHECK:    ldr  r0, [r0]
37; CHECK:    bx   lr
38entry:
39  %0 = load i32, i32* @localvar, align 4
40  ret i32 %0
41}
42
43define dso_local i32 @getLocalCommon() {
44; CHECK-LABEL: getLocalCommon:
45; CHECK:    movw r0, :lower16:localcommon
46; CHECK:    movt r0, :upper16:localcommon
47; CHECK:    ldr  r0, [r0]
48; CHECK:    bx   lr
49entry:
50  %0 = load i32, i32* @localcommon, align 4
51  ret i32 %0
52}
53
54define dso_local i32 @getExtVar() {
55; CHECK-LABEL: getExtVar:
56; CHECK:    movw r0, :lower16:__imp_extvar
57; CHECK:    movt r0, :upper16:__imp_extvar
58; CHECK:    ldr  r0, [r0]
59; CHECK:    ldr  r0, [r0]
60; CHECK:    bx   lr
61entry:
62  %0 = load i32, i32* @extvar, align 4
63  ret i32 %0
64}
65
66define dso_local void @callFunc() {
67; CHECK-LABEL: callFunc:
68; CHECK:    b otherFunc
69entry:
70  tail call void @otherFunc()
71  ret void
72}
73
74declare dso_local void @otherFunc()
75
76; CHECK:        .section        .rdata$.refptr.var,"dr",discard,.refptr.var
77; CHECK:        .globl  .refptr.var
78; CHECK: .refptr.var:
79; CHECK:        .long   var
80