1; RUN: llc -mtriple x86_64-pc-win32 \
2; RUN:     -relocation-model=static  < %s | FileCheck --check-prefix=COFF_S %s
3; RUN: llc -mtriple x86_64-pc-win32 \
4; RUN:     -relocation-model=pic     < %s | FileCheck --check-prefix=COFF %s
5; RUN: llc -mtriple x86_64-pc-win32 \
6; RUN:  -relocation-model=dynamic-no-pic < %s | FileCheck --check-prefix=COFF %s
7
8
9; 32 bits
10
11; RUN: llc -mtriple i386-pc-win32 \
12; RUN:    -relocation-model=static  < %s | FileCheck --check-prefix=COFF32 %s
13; RUN: llc -mtriple i386-pc-win32 \
14; RUN:     -relocation-model=pic     < %s | FileCheck --check-prefix=COFF32 %s
15; RUN: llc -mtriple i386-pc-win32 \
16; RUN:   -relocation-model=dynamic-no-pic < %s | \
17; RUN:   FileCheck --check-prefix=COFF32 %s
18
19; globals
20
21@strong_default_global = global i32 42
22define i32* @get_strong_default_global() {
23  ret i32* @strong_default_global
24}
25; COFF: leaq strong_default_global(%rip), %rax
26; COFF_S: movl $strong_default_global, %eax
27; COFF32: movl $_strong_default_global, %eax
28
29@weak_default_global = weak global i32 42
30define i32* @get_weak_default_global() {
31  ret i32* @weak_default_global
32}
33; COFF: leaq weak_default_global(%rip), %rax
34; COFF_S: movl $weak_default_global, %eax
35; COFF32: movl $_weak_default_global, %eax
36
37@external_default_global = external global i32
38define i32* @get_external_default_global() {
39  ret i32* @external_default_global
40}
41; COFF: leaq external_default_global(%rip), %rax
42; COFF_S: movl $external_default_global, %eax
43; COFF32: movl $_external_default_global, %eax
44
45
46@strong_local_global = dso_local global i32 42
47define i32* @get_strong_local_global() {
48  ret i32* @strong_local_global
49}
50; COFF: leaq strong_local_global(%rip), %rax
51; COFF_S: movl $strong_local_global, %eax
52; COFF32: movl $_strong_local_global, %eax
53
54@weak_local_global = weak dso_local global i32 42
55define i32* @get_weak_local_global() {
56  ret i32* @weak_local_global
57}
58; COFF: leaq weak_local_global(%rip), %rax
59; COFF_S: movl $weak_local_global, %eax
60; COFF32: movl $_weak_local_global, %eax
61
62@external_local_global = external dso_local global i32
63define i32* @get_external_local_global() {
64  ret i32* @external_local_global
65}
66; COFF: leaq external_local_global(%rip), %rax
67; COFF_S: movl $external_local_global, %eax
68; COFF32: movl $_external_local_global, %eax
69
70
71@strong_preemptable_global = dso_preemptable global i32 42
72define i32* @get_strong_preemptable_global() {
73  ret i32* @strong_preemptable_global
74}
75; COFF: leaq strong_preemptable_global(%rip), %rax
76; COFF_S: movl $strong_preemptable_global, %eax
77; COFF32: movl $_strong_preemptable_global, %eax
78
79@weak_preemptable_global = weak dso_preemptable global i32 42
80define i32* @get_weak_preemptable_global() {
81  ret i32* @weak_preemptable_global
82}
83; COFF: leaq weak_preemptable_global(%rip), %rax
84; COFF_S: movl $weak_preemptable_global, %eax
85; COFF32: movl $_weak_preemptable_global, %eax
86
87@external_preemptable_global = external dso_preemptable global i32
88define i32* @get_external_preemptable_global() {
89  ret i32* @external_preemptable_global
90}
91; COFF: leaq external_preemptable_global(%rip), %rax
92; COFF_S: movl $external_preemptable_global, %eax
93; COFF32: movl $_external_preemptable_global, %eax
94
95
96; aliases
97@aliasee = global i32 42
98
99@strong_default_alias = alias i32, i32* @aliasee
100define i32* @get_strong_default_alias() {
101  ret i32* @strong_default_alias
102}
103; COFF: leaq strong_default_alias(%rip), %rax
104; COFF_S: movl $strong_default_alias, %eax
105; COFF32: movl $_strong_default_alias, %eax
106
107@weak_default_alias = weak alias i32, i32* @aliasee
108define i32* @get_weak_default_alias() {
109  ret i32* @weak_default_alias
110}
111; COFF: leaq weak_default_alias(%rip), %rax
112; COFF_S: movl $weak_default_alias, %eax
113; COFF32: movl $_weak_default_alias, %eax
114
115
116@strong_local_alias = dso_local alias i32, i32* @aliasee
117define i32* @get_strong_local_alias() {
118  ret i32* @strong_local_alias
119}
120; COFF: leaq strong_local_alias(%rip), %rax
121; COFF_S: movl $strong_local_alias, %eax
122; COFF32: movl $_strong_local_alias, %eax
123
124@weak_local_alias = weak dso_local alias i32, i32* @aliasee
125define i32* @get_weak_local_alias() {
126  ret i32* @weak_local_alias
127}
128; COFF: leaq weak_local_alias(%rip), %rax
129; COFF_S: movl $weak_local_alias, %eax
130; COFF32: movl $_weak_local_alias, %eax
131
132
133@strong_preemptable_alias = dso_preemptable alias i32, i32* @aliasee
134define i32* @get_strong_preemptable_alias() {
135  ret i32* @strong_preemptable_alias
136}
137; COFF: leaq strong_preemptable_alias(%rip), %rax
138; COFF_S: movl $strong_preemptable_alias, %eax
139; COFF32: movl $_strong_preemptable_alias, %eax
140
141@weak_preemptable_alias = weak dso_preemptable alias i32, i32* @aliasee
142define i32* @get_weak_preemptable_alias() {
143  ret i32* @weak_preemptable_alias
144}
145; COFF: leaq weak_preemptable_alias(%rip), %rax
146; COFF_S: movl $weak_preemptable_alias, %eax
147; COFF32: movl $_weak_preemptable_alias, %eax
148
149
150; functions
151
152define void @strong_default_function() {
153  ret void
154}
155define void()* @get_strong_default_function() {
156  ret void()* @strong_default_function
157}
158; COFF: leaq strong_default_function(%rip), %rax
159; COFF_S: movl $strong_default_function, %eax
160; COFF32: movl $_strong_default_function, %eax
161
162define weak void @weak_default_function() {
163  ret void
164}
165define void()* @get_weak_default_function() {
166  ret void()* @weak_default_function
167}
168; COFF: leaq weak_default_function(%rip), %rax
169; COFF_S: movl $weak_default_function, %eax
170; COFF32: movl $_weak_default_function, %eax
171
172declare void @external_default_function()
173define void()* @get_external_default_function() {
174  ret void()* @external_default_function
175}
176; COFF: leaq external_default_function(%rip), %rax
177; COFF_S: movl $external_default_function, %eax
178; COFF32: movl $_external_default_function, %eax
179
180
181define dso_local void @strong_local_function() {
182  ret void
183}
184define void()* @get_strong_local_function() {
185  ret void()* @strong_local_function
186}
187; COFF: leaq strong_local_function(%rip), %rax
188; COFF_S: movl $strong_local_function, %eax
189; COFF32: movl $_strong_local_function, %eax
190
191define weak dso_local void @weak_local_function() {
192  ret void
193}
194define void()* @get_weak_local_function() {
195  ret void()* @weak_local_function
196}
197; COFF: leaq weak_local_function(%rip), %rax
198; COFF_S: movl $weak_local_function, %eax
199; COFF32: movl $_weak_local_function, %eax
200
201declare dso_local void @external_local_function()
202define void()* @get_external_local_function() {
203  ret void()* @external_local_function
204}
205; COFF: leaq external_local_function(%rip), %rax
206; COFF_S: movl $external_local_function, %eax
207; COFF32: movl $_external_local_function, %eax
208
209
210define dso_preemptable void @strong_preemptable_function() {
211  ret void
212}
213define void()* @get_strong_preemptable_function() {
214  ret void()* @strong_preemptable_function
215}
216; COFF: leaq strong_preemptable_function(%rip), %rax
217; COFF_S: movl $strong_preemptable_function, %eax
218; COFF32: movl $_strong_preemptable_function, %eax
219
220define weak dso_preemptable void @weak_preemptable_function() {
221  ret void
222}
223define void()* @get_weak_preemptable_function() {
224  ret void()* @weak_preemptable_function
225}
226; COFF: leaq weak_preemptable_function(%rip), %rax
227; COFF_S: movl $weak_preemptable_function, %eax
228; COFF32: movl $_weak_preemptable_function, %eax
229
230declare dso_preemptable void @external_preemptable_function()
231define void()* @get_external_preemptable_function() {
232  ret void()* @external_preemptable_function
233}
234; COFF: leaq external_preemptable_function(%rip), %rax
235; COFF_S: movl $external_preemptable_function, %eax
236; COFF32: movl $_external_preemptable_function, %eax
237