mixed-ptr-sizes-i686.ll
11.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc < %s | FileCheck %s --check-prefixes=ALL,CHECK
; RUN: llc -O0 < %s | FileCheck %s --check-prefixes=ALL,CHECK-O0
; Source to regenerate:
; struct Foo {
; int * __ptr32 p32;
; int * __ptr64 p64;
; __attribute__((address_space(9))) int *p_other;
; };
; void use_foo(Foo *f);
; void test_sign_ext(Foo *f, int * __ptr32 __sptr i) {
; f->p64 = i;
; use_foo(f);
; }
; void test_zero_ext(Foo *f, int * __ptr32 __uptr i) {
; f->p64 = i;
; use_foo(f);
; }
; void test_trunc(Foo *f, int * __ptr64 i) {
; f->p32 = i;
; use_foo(f);
; }
; void test_noop1(Foo *f, int * __ptr32 i) {
; f->p32 = i;
; use_foo(f);
; }
; void test_noop2(Foo *f, int * __ptr64 i) {
; f->p64 = i;
; use_foo(f);
; }
; void test_null_arg(Foo *f) {
; test_noop2(f, 0);
; }
; void test_unrecognized(Foo *f, __attribute__((address_space(14))) int *i) {
; f->p64 = (int * __ptr64)i;
; use_foo(f);
; }
; void test_unrecognized2(Foo *f, int * __ptr64 i) {
; f->p_other = i;
; use_foo(f);
; }
;
; $ clang -cc1 -triple x86_64-windows-msvc -fms-extensions -O2 -S t.cpp
target datalayout = "e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:32-n8:16:32-a:0:32-S32"
target triple = "i686-unknown-windows-msvc"
%struct.Foo = type { i32*, i32 addrspace(272)*, i32 addrspace(9)* }
declare dso_local void @use_foo(%struct.Foo*)
define dso_local void @test_sign_ext(%struct.Foo* %f, i32* %i) {
; CHECK-LABEL: test_sign_ext:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: movl {{[0-9]+}}(%esp), %eax
; CHECK-NEXT: movl {{[0-9]+}}(%esp), %ecx
; CHECK-NEXT: movl %ecx, 8(%eax)
; CHECK-NEXT: sarl $31, %ecx
; CHECK-NEXT: movl %ecx, 12(%eax)
; CHECK-NEXT: jmp _use_foo # TAILCALL
;
; CHECK-O0-LABEL: test_sign_ext:
; CHECK-O0: # %bb.0: # %entry
; CHECK-O0-NEXT: movl {{[0-9]+}}(%esp), %eax
; CHECK-O0-NEXT: movl {{[0-9]+}}(%esp), %ecx
; CHECK-O0-NEXT: movl %eax, %edx
; CHECK-O0-NEXT: sarl $31, %edx
; CHECK-O0-NEXT: movl %eax, 8(%ecx)
; CHECK-O0-NEXT: movl %edx, 12(%ecx)
; CHECK-O0-NEXT: jmp _use_foo # TAILCALL
entry:
%0 = addrspacecast i32* %i to i32 addrspace(272)*
%p64 = getelementptr inbounds %struct.Foo, %struct.Foo* %f, i32 0, i32 1
store i32 addrspace(272)* %0, i32 addrspace(272)** %p64, align 8
tail call void @use_foo(%struct.Foo* %f)
ret void
}
define dso_local void @test_zero_ext(%struct.Foo* %f, i32 addrspace(271)* %i) {
; ALL-LABEL: test_zero_ext:
; ALL: # %bb.0: # %entry
; ALL-NEXT: movl {{[0-9]+}}(%esp), %eax
; ALL-NEXT: movl {{[0-9]+}}(%esp), %ecx
; ALL-NEXT: movl %eax, 8(%ecx)
; ALL-NEXT: movl $0, 12(%ecx)
; ALL-NEXT: jmp _use_foo # TAILCALL
entry:
%0 = addrspacecast i32 addrspace(271)* %i to i32 addrspace(272)*
%p64 = getelementptr inbounds %struct.Foo, %struct.Foo* %f, i32 0, i32 1
store i32 addrspace(272)* %0, i32 addrspace(272)** %p64, align 8
tail call void @use_foo(%struct.Foo* %f)
ret void
}
define dso_local void @test_trunc(%struct.Foo* %f, i32 addrspace(272)* %i) {
; CHECK-LABEL: test_trunc:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: movl {{[0-9]+}}(%esp), %eax
; CHECK-NEXT: movl {{[0-9]+}}(%esp), %ecx
; CHECK-NEXT: movl %eax, (%ecx)
; CHECK-NEXT: jmp _use_foo # TAILCALL
;
; CHECK-O0-LABEL: test_trunc:
; CHECK-O0: # %bb.0: # %entry
; CHECK-O0-NEXT: pushl %eax
; CHECK-O0-NEXT: movl {{[0-9]+}}(%esp), %eax
; CHECK-O0-NEXT: movl {{[0-9]+}}(%esp), %ecx
; CHECK-O0-NEXT: movl {{[0-9]+}}(%esp), %edx
; CHECK-O0-NEXT: movl %ecx, (%edx)
; CHECK-O0-NEXT: movl %eax, (%esp) # 4-byte Spill
; CHECK-O0-NEXT: popl %eax
; CHECK-O0-NEXT: jmp _use_foo # TAILCALL
entry:
%0 = addrspacecast i32 addrspace(272)* %i to i32*
%p32 = getelementptr inbounds %struct.Foo, %struct.Foo* %f, i32 0, i32 0
store i32* %0, i32** %p32, align 8
tail call void @use_foo(%struct.Foo* %f)
ret void
}
define dso_local void @test_noop1(%struct.Foo* %f, i32* %i) {
; ALL-LABEL: test_noop1:
; ALL: # %bb.0: # %entry
; ALL-NEXT: movl {{[0-9]+}}(%esp), %eax
; ALL-NEXT: movl {{[0-9]+}}(%esp), %ecx
; ALL-NEXT: movl %eax, (%ecx)
; ALL-NEXT: jmp _use_foo # TAILCALL
entry:
%p32 = getelementptr inbounds %struct.Foo, %struct.Foo* %f, i32 0, i32 0
store i32* %i, i32** %p32, align 8
tail call void @use_foo(%struct.Foo* %f)
ret void
}
define dso_local void @test_noop2(%struct.Foo* %f, i32 addrspace(272)* %i) {
; CHECK-LABEL: test_noop2:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: movl {{[0-9]+}}(%esp), %eax
; CHECK-NEXT: movl {{[0-9]+}}(%esp), %ecx
; CHECK-NEXT: movl {{[0-9]+}}(%esp), %edx
; CHECK-NEXT: movl %ecx, 12(%edx)
; CHECK-NEXT: movl %eax, 8(%edx)
; CHECK-NEXT: jmp _use_foo # TAILCALL
;
; CHECK-O0-LABEL: test_noop2:
; CHECK-O0: # %bb.0: # %entry
; CHECK-O0-NEXT: movl {{[0-9]+}}(%esp), %eax
; CHECK-O0-NEXT: movl {{[0-9]+}}(%esp), %ecx
; CHECK-O0-NEXT: movl {{[0-9]+}}(%esp), %edx
; CHECK-O0-NEXT: movl %ecx, 8(%edx)
; CHECK-O0-NEXT: movl %eax, 12(%edx)
; CHECK-O0-NEXT: jmp _use_foo # TAILCALL
entry:
%p64 = getelementptr inbounds %struct.Foo, %struct.Foo* %f, i32 0, i32 1
store i32 addrspace(272)* %i, i32 addrspace(272)** %p64, align 8
tail call void @use_foo(%struct.Foo* %f)
ret void
}
; Test that null can be passed as a 64-bit pointer.
define dso_local void @test_null_arg(%struct.Foo* %f) {
; CHECK-LABEL: test_null_arg:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: pushl $0
; CHECK-NEXT: pushl $0
; CHECK-NEXT: pushl {{[0-9]+}}(%esp)
; CHECK-NEXT: calll _test_noop2
; CHECK-NEXT: addl $12, %esp
; CHECK-NEXT: retl
;
; CHECK-O0-LABEL: test_null_arg:
; CHECK-O0: # %bb.0: # %entry
; CHECK-O0-NEXT: subl $12, %esp
; CHECK-O0-NEXT: movl {{[0-9]+}}(%esp), %eax
; CHECK-O0-NEXT: movl %esp, %ecx
; CHECK-O0-NEXT: movl %eax, (%ecx)
; CHECK-O0-NEXT: movl $0, 8(%ecx)
; CHECK-O0-NEXT: movl $0, 4(%ecx)
; CHECK-O0-NEXT: calll _test_noop2
; CHECK-O0-NEXT: addl $12, %esp
; CHECK-O0-NEXT: retl
entry:
call void @test_noop2(%struct.Foo* %f, i32 addrspace(272)* null)
ret void
}
define dso_local void @test_unrecognized(%struct.Foo* %f, i32 addrspace(14)* %i) {
; CHECK-LABEL: test_unrecognized:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: movl {{[0-9]+}}(%esp), %eax
; CHECK-NEXT: movl {{[0-9]+}}(%esp), %ecx
; CHECK-NEXT: movl %ecx, 8(%eax)
; CHECK-NEXT: sarl $31, %ecx
; CHECK-NEXT: movl %ecx, 12(%eax)
; CHECK-NEXT: jmp _use_foo # TAILCALL
;
; CHECK-O0-LABEL: test_unrecognized:
; CHECK-O0: # %bb.0: # %entry
; CHECK-O0-NEXT: movl {{[0-9]+}}(%esp), %eax
; CHECK-O0-NEXT: movl {{[0-9]+}}(%esp), %ecx
; CHECK-O0-NEXT: movl %eax, %edx
; CHECK-O0-NEXT: sarl $31, %edx
; CHECK-O0-NEXT: movl %eax, 8(%ecx)
; CHECK-O0-NEXT: movl %edx, 12(%ecx)
; CHECK-O0-NEXT: jmp _use_foo # TAILCALL
entry:
%0 = addrspacecast i32 addrspace(14)* %i to i32 addrspace(272)*
%p64 = getelementptr inbounds %struct.Foo, %struct.Foo* %f, i32 0, i32 1
store i32 addrspace(272)* %0, i32 addrspace(272)** %p64, align 8
tail call void @use_foo(%struct.Foo* %f)
ret void
}
define dso_local void @test_unrecognized2(%struct.Foo* %f, i32 addrspace(272)* %i) {
; CHECK-LABEL: test_unrecognized2:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: movl {{[0-9]+}}(%esp), %eax
; CHECK-NEXT: movl {{[0-9]+}}(%esp), %ecx
; CHECK-NEXT: movl %eax, 16(%ecx)
; CHECK-NEXT: jmp _use_foo # TAILCALL
;
; CHECK-O0-LABEL: test_unrecognized2:
; CHECK-O0: # %bb.0: # %entry
; CHECK-O0-NEXT: pushl %eax
; CHECK-O0-NEXT: movl {{[0-9]+}}(%esp), %eax
; CHECK-O0-NEXT: movl {{[0-9]+}}(%esp), %ecx
; CHECK-O0-NEXT: movl {{[0-9]+}}(%esp), %edx
; CHECK-O0-NEXT: movl %ecx, 16(%edx)
; CHECK-O0-NEXT: movl %eax, (%esp) # 4-byte Spill
; CHECK-O0-NEXT: popl %eax
; CHECK-O0-NEXT: jmp _use_foo # TAILCALL
entry:
%0 = addrspacecast i32 addrspace(272)* %i to i32 addrspace(9)*
%p_other = getelementptr inbounds %struct.Foo, %struct.Foo* %f, i32 0, i32 2
store i32 addrspace(9)* %0, i32 addrspace(9)** %p_other, align 8
tail call void @use_foo(%struct.Foo* %f)
ret void
}
define i32 @test_load_sptr32(i32 addrspace(270)* %i) {
; CHECK-LABEL: test_load_sptr32:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: movl {{[0-9]+}}(%esp), %eax
; CHECK-NEXT: movl (%eax), %eax
; CHECK-NEXT: retl
; CHECK-O0-LABEL: test_load_sptr32:
; CHECK-O0: # %bb.0: # %entry
; CHECK-O0-NEXT: movl {{[0-9]+}}(%esp), %eax
; CHECK-O0-NEXT: movl (%eax), %eax
; CHECK-O0-NEXT: retl
entry:
%0 = load i32, i32 addrspace(270)* %i, align 4
ret i32 %0
}
define i32 @test_load_uptr32(i32 addrspace(271)* %i) {
; CHECK-LABEL: test_load_uptr32:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: movl {{[0-9]+}}(%esp), %eax
; CHECK-NEXT: movl (%eax), %eax
; CHECK-NEXT: retl
; CHECK-O0-LABEL: test_load_uptr32:
; CHECK-O0: # %bb.0: # %entry
; CHECK-O0-NEXT: movl {{[0-9]+}}(%esp), %eax
; CHECK-O0-NEXT: movl (%eax), %eax
; CHECK-O0-NEXT: retl
entry:
%0 = load i32, i32 addrspace(271)* %i, align 4
ret i32 %0
}
define i32 @test_load_ptr64(i32 addrspace(272)* %i) {
; CHECK-LABEL: test_load_ptr64:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: movl {{[0-9]+}}(%esp), %eax
; CHECK-NEXT: movl (%eax), %eax
; CHECK-NEXT: retl
; CHECK-O0-LABEL: test_load_ptr64:
; CHECK-O0: # %bb.0: # %entry
; CHECK-O0-NEXT: pushl %eax
; CHECK-O0-NEXT: movl {{[0-9]+}}(%esp), %eax
; CHECK-O0-NEXT: movl {{[0-9]+}}(%esp), %ecx
; CHECK-O0-NEXT: movl (%ecx), %ecx
; CHECK-O0-NEXT: movl %eax, (%esp)
; CHECK-O0-NEXT: movl %ecx, %eax
; CHECK-O0-NEXT: popl %ecx
; CHECK-O0-NEXT: retl
entry:
%0 = load i32, i32 addrspace(272)* %i, align 8
ret i32 %0
}
define void @test_store_sptr32(i32 addrspace(270)* %s, i32 %i) {
; CHECK-LABEL: test_store_sptr32:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: movl {{[0-9]+}}(%esp), %eax
; CHECK-NEXT: movl {{[0-9]+}}(%esp), %ecx
; CHECK-NEXT: movl %eax, (%ecx)
; CHECK-NEXT: retl
; CHECK-O0-LABEL: test_store_sptr32:
; CHECK-O0: # %bb.0: # %entry
; CHECK-O0-NEXT: movl {{[0-9]+}}(%esp), %eax
; CHECK-O0-NEXT: movl {{[0-9]+}}(%esp), %ecx
; CHECK-O0-NEXT: movl %eax, (%ecx)
; CHECK-O0-NEXT: retl
entry:
store i32 %i, i32 addrspace(270)* %s, align 4
ret void
}
define void @test_store_uptr32(i32 addrspace(271)* %s, i32 %i) {
; CHECK-LABEL: test_store_uptr32:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: movl {{[0-9]+}}(%esp), %eax
; CHECK-NEXT: movl {{[0-9]+}}(%esp), %ecx
; CHECK-NEXT: movl %eax, (%ecx)
; CHECK-NEXT: retl
; CHECK-O0-LABEL: test_store_uptr32:
; CHECK-O0: # %bb.0: # %entry
; CHECK-O0-NEXT: movl {{[0-9]+}}(%esp), %eax
; CHECK-O0-NEXT: movl {{[0-9]+}}(%esp), %ecx
; CHECK-O0-NEXT: movl %eax, (%ecx)
; CHECK-O0-NEXT: retl
entry:
store i32 %i, i32 addrspace(271)* %s, align 4
ret void
}
define void @test_store_ptr64(i32 addrspace(272)* %s, i32 %i) {
; CHECK-LABEL: test_store_ptr64:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: movl {{[0-9]+}}(%esp), %eax
; CHECK-NEXT: movl {{[0-9]+}}(%esp), %ecx
; CHECK-NEXT: movl %eax, (%ecx)
; CHECK-NEXT: retl
; CHECK-O0-LABEL: test_store_ptr64:
; CHECK-O0: # %bb.0: # %entry
; CHECK-O0-NEXT: movl {{[0-9]+}}(%esp), %eax
; CHECK-O0-NEXT: movl {{[0-9]+}}(%esp), %ecx
; CHECK-O0-NEXT: movl {{[0-9]+}}(%esp), %edx
; CHECK-O0-NEXT: movl %edx, (%ecx)
; CHECK-O0-NEXT: retl
entry:
store i32 %i, i32 addrspace(272)* %s, align 8
ret void
}