Skip to content

Commit a12068a

Browse files
committed
use opaque pointers
1 parent 074430b commit a12068a

File tree

1 file changed

+102
-102
lines changed

1 file changed

+102
-102
lines changed

llvm/test/CodeGen/SystemZ/mixed-ptr-sizes.ll

Lines changed: 102 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -98,88 +98,88 @@
9898
; return 0;
9999
;}
100100

101-
%struct.Foo = type { i32 addrspace(1)*, i32*, i8* }
102-
declare dso_local void @use_foo(%struct.Foo*)
101+
%struct.Foo = type { ptr addrspace(1), ptr, ptr }
102+
declare void @use_foo(ptr)
103103

104-
define void @ptr32_to_ptr(%struct.Foo* %f, i32 addrspace(1)* %i) {
104+
define void @ptr32_to_ptr(ptr %f, ptr addrspace(1) %i) {
105+
entry:
105106
; CHECK-LABEL: ptr32_to_ptr:
106107
; CHECK: llgtr 0, 2
107108
; CHECK-NEXT: stg 0, 8(1)
108-
entry:
109-
%0 = addrspacecast i32 addrspace(1)* %i to i32*
110-
%p64 = getelementptr inbounds %struct.Foo, %struct.Foo* %f, i64 0, i32 1
111-
store i32* %0, i32** %p64, align 8
112-
tail call void @use_foo(%struct.Foo* %f)
109+
%0 = addrspacecast ptr addrspace(1) %i to ptr
110+
%p64 = getelementptr inbounds %struct.Foo, ptr %f, i64 0, i32 1
111+
store ptr %0, ptr %p64, align 8
112+
tail call void @use_foo(ptr %f)
113113
ret void
114114
}
115115

116-
define void @ptr_to_ptr32(%struct.Foo* %f, i32* %i) {
116+
define void @ptr_to_ptr32(ptr %f, ptr %i) {
117117
entry:
118118
; CHECK-LABEL: ptr_to_ptr32:
119119
; CHECK: nilh 2, 32767
120120
; CHECK-NEXT: st 2, 0(1)
121-
%0 = addrspacecast i32* %i to i32 addrspace(1)*
122-
%p32 = getelementptr inbounds %struct.Foo, %struct.Foo* %f, i64 0, i32 0
123-
store i32 addrspace(1)* %0, i32 addrspace(1)** %p32, align 8
124-
tail call void @use_foo(%struct.Foo* %f)
121+
%0 = addrspacecast ptr %i to ptr addrspace(1)
122+
%p32 = getelementptr inbounds %struct.Foo, ptr %f, i64 0, i32 0
123+
store ptr addrspace(1) %0, ptr %p32, align 8
124+
tail call void @use_foo(ptr %f)
125125
ret void
126126
}
127127

128-
define void @ptr32_to_ptr32(%struct.Foo* %f, i32 addrspace(1)* %i) {
128+
define void @ptr32_to_ptr32(ptr %f, ptr addrspace(1) %i) {
129129
entry:
130130
; CHECK-LABEL: ptr32_to_ptr32:
131131
; CHECK: st 2, 0(1)
132-
%p32 = getelementptr inbounds %struct.Foo, %struct.Foo* %f, i64 0, i32 0
133-
store i32 addrspace(1)* %i, i32 addrspace(1)** %p32, align 8
134-
tail call void @use_foo(%struct.Foo* %f)
132+
%p32 = getelementptr inbounds %struct.Foo, ptr %f, i64 0, i32 0
133+
store ptr addrspace(1) %i, ptr %p32, align 8
134+
tail call void @use_foo(ptr %f)
135135
ret void
136136
}
137137

138-
define void @ptr_to_ptr(%struct.Foo* %f, i32* %i) {
138+
define void @ptr_to_ptr(ptr %f, ptr %i) {
139139
; CHECK-LABEL: ptr_to_ptr:
140140
; CHECK: stg 2, 8(1)
141-
%p64 = getelementptr inbounds %struct.Foo, %struct.Foo* %f, i64 0, i32 1
142-
store i32* %i, i32** %p64, align 8
143-
tail call void @use_foo(%struct.Foo* %f)
141+
%p64 = getelementptr inbounds %struct.Foo, ptr %f, i64 0, i32 1
142+
store ptr %i, ptr %p64, align 8
143+
tail call void @use_foo(ptr %f)
144144
ret void
145145
}
146146

147-
define void @test_indexing(%struct.Foo* %f) {
147+
define void @test_indexing(ptr %f) {
148148
entry:
149149
; CHECK-LABEL: test_indexing:
150150
; CHECK: l 0, 1032
151151
; CHECK: llgtr 0, 0
152152
; CHECK: stg 0, 16(1)
153-
%0 = load i8 addrspace(1)*, i8 addrspace(1)** inttoptr (i64 1032 to i8 addrspace(1)**), align 8
154-
%1 = addrspacecast i8 addrspace(1)* %0 to i8*
155-
%cp64 = getelementptr inbounds %struct.Foo, %struct.Foo* %f, i64 0, i32 2
156-
store i8* %1, i8** %cp64, align 8
157-
tail call void @use_foo(%struct.Foo* %f)
153+
%0 = load ptr addrspace(1), ptr inttoptr (i64 1032 to ptr), align 8
154+
%1 = addrspacecast ptr addrspace(1) %0 to ptr
155+
%cp64 = getelementptr inbounds %struct.Foo, ptr %f, i64 0, i32 2
156+
store ptr %1, ptr %cp64, align 8
157+
tail call void @use_foo(ptr %f)
158158
ret void
159159
}
160160

161-
define void @test_indexing_2(%struct.Foo* %f) {
161+
define void @test_indexing_2(ptr %f) {
162162
entry:
163163
; CHECK-LABEL: test_indexing_2:
164164
; CHECK: lhi 0, 16
165165
; CHECK-NEXT: a 0, 1032
166166
; CHECK-NEXT: llgtr 2, 0
167167
; CHECK: lg 0, 24(2)
168168
; CHECK: stg 0, 16(1)
169-
%0 = load i8** addrspace(1)*, i8** addrspace(1)** inttoptr (i64 1032 to i8** addrspace(1)**), align 8
170-
%arrayidx = getelementptr inbounds i8**, i8** addrspace(1)* %0, i32 2
171-
%1 = load i8**, i8** addrspace(1)* %arrayidx, align 8
172-
%arrayidx1 = getelementptr inbounds i8*, i8** %1, i64 3
173-
%2 = bitcast i8** %arrayidx1 to i64*
174-
%3 = load i64, i64* %2, align 8
175-
%cp64 = getelementptr inbounds %struct.Foo, %struct.Foo* %f, i64 0, i32 2
176-
%4 = bitcast i8** %cp64 to i64*
177-
store i64 %3, i64* %4, align 8
178-
tail call void @use_foo(%struct.Foo* %f)
169+
%0 = load ptr addrspace(1), ptr inttoptr (i64 1032 to ptr), align 8
170+
%arrayidx = getelementptr inbounds ptr, ptr addrspace(1) %0, i32 2
171+
%1 = load ptr, ptr addrspace(1) %arrayidx, align 8
172+
%arrayidx1 = getelementptr inbounds ptr, ptr %1, i64 3
173+
%2 = bitcast ptr %arrayidx1 to ptr
174+
%3 = load i64, ptr %2, align 8
175+
%cp64 = getelementptr inbounds %struct.Foo, ptr %f, i64 0, i32 2
176+
%4 = bitcast ptr %cp64 to ptr
177+
store i64 %3, ptr %4, align 8
178+
tail call void @use_foo(ptr %f)
179179
ret void
180180
}
181181

182-
define i64* @test_misc() {
182+
define ptr @test_misc() {
183183
entry:
184184
; CHECK-LABEL: test_misc:
185185
; CHECK: lhi 0, 88
@@ -189,20 +189,20 @@ entry:
189189
; CHECK-NEXT: lg 1, 8(1)
190190
; CHECK-NEXT: lg 1, 904(1)
191191
; CHECK-NEXT: lg 3, 1192(1)
192-
%0 = load i8**** addrspace(1)*, i8**** addrspace(1)** inttoptr (i64 1208 to i8**** addrspace(1)**), align 8
193-
%arrayidx = getelementptr inbounds i8****, i8**** addrspace(1)* %0, i32 11
194-
%1 = load i8****, i8**** addrspace(1)* %arrayidx, align 8
195-
%arrayidx1 = getelementptr inbounds i8***, i8**** %1, i64 1
196-
%2 = load i8***, i8**** %arrayidx1, align 8
197-
%arrayidx2 = getelementptr inbounds i8**, i8*** %2, i64 113
198-
%3 = load i8**, i8*** %arrayidx2, align 8
199-
%arrayidx3 = getelementptr inbounds i8*, i8** %3, i64 149
200-
%4 = bitcast i8** %arrayidx3 to i64**
201-
%5 = load i64*, i64** %4, align 8
202-
ret i64* %5
192+
%0 = load ptr addrspace(1), ptr inttoptr (i64 1208 to ptr), align 8
193+
%arrayidx = getelementptr inbounds ptr, ptr addrspace(1) %0, i32 11
194+
%1 = load ptr, ptr addrspace(1) %arrayidx, align 8
195+
%arrayidx1 = getelementptr inbounds ptr, ptr %1, i64 1
196+
%2 = load ptr, ptr %arrayidx1, align 8
197+
%arrayidx2 = getelementptr inbounds ptr, ptr %2, i64 113
198+
%3 = load ptr, ptr %arrayidx2, align 8
199+
%arrayidx3 = getelementptr inbounds ptr, ptr %3, i64 149
200+
%4 = bitcast ptr %arrayidx3 to ptr
201+
%5 = load ptr, ptr %4, align 8
202+
ret ptr %5
203203
}
204204

205-
define i8 addrspace(1)* addrspace(1)* @test_misc_2() {
205+
define ptr addrspace(1) @test_misc_2() {
206206
entry:
207207
; CHECK-LABEL: test_misc_2:
208208
; CHECK: lhi 0, 544
@@ -211,25 +211,25 @@ entry:
211211
; CHECK: lhi 0, 24
212212
; CHECK: a 0, 0(1)
213213
; CHECK: llgtr 1, 0
214-
%0 = load i8 addrspace(1)* addrspace(1)* addrspace(1)* addrspace(1)*, i8 addrspace(1)* addrspace(1)* addrspace(1)* addrspace(1)** inttoptr (i64 16 to i8 addrspace(1)* addrspace(1)* addrspace(1)* addrspace(1)**), align 16
215-
%arrayidx = getelementptr inbounds i8 addrspace(1)* addrspace(1)* addrspace(1)*, i8 addrspace(1)* addrspace(1)* addrspace(1)* addrspace(1)* %0, i32 136
216-
%1 = load i8 addrspace(1)* addrspace(1)* addrspace(1)*, i8 addrspace(1)* addrspace(1)* addrspace(1)* addrspace(1)* %arrayidx, align 4
217-
%arrayidx1 = getelementptr inbounds i8 addrspace(1)* addrspace(1)*, i8 addrspace(1)* addrspace(1)* addrspace(1)* %1, i32 6
218-
%2 = load i8 addrspace(1)* addrspace(1)*, i8 addrspace(1)* addrspace(1)* addrspace(1)* %arrayidx1, align 4
219-
ret i8 addrspace(1)* addrspace(1)* %2
214+
%0 = load ptr addrspace(1), ptr inttoptr (i64 16 to ptr), align 16
215+
%arrayidx = getelementptr inbounds ptr addrspace(1), ptr addrspace(1) %0, i32 136
216+
%1 = load ptr addrspace(1), ptr addrspace(1) %arrayidx, align 4
217+
%arrayidx1 = getelementptr inbounds ptr addrspace(1), ptr addrspace(1) %1, i32 6
218+
%2 = load ptr addrspace(1), ptr addrspace(1) %arrayidx1, align 4
219+
ret ptr addrspace(1) %2
220220
}
221221

222-
define zeroext i16 @test_misc_3() local_unnamed_addr #3 {
222+
define zeroext i16 @test_misc_3() {
223223
entry:
224224
; CHECK-LABEL: test_misc_3:
225-
; CHECK: lhi 0, 36
226-
; CHECK-NEXT: a 0, 548
225+
; CHECK: a 0, 548
227226
; CHECK-NEXT: llgtr 1, 0
228227
; CHECK-NEXT: llgh 3, 0(1)
229-
%0 = load i16 addrspace(1)*, i16 addrspace(1)** inttoptr (i64 548 to i16 addrspace(1)**), align 4
230-
%arrayidx2 = getelementptr inbounds i16, i16 addrspace(1)* %0, i32 18
231-
%arrayidx = addrspacecast i16 addrspace(1)* %arrayidx2 to i16*
232-
%1 = load i16, i16* %arrayidx, align 2
228+
; CHECK-NEXT: b 2(7)
229+
%0 = load ptr addrspace(1), ptr inttoptr (i64 548 to ptr), align 4
230+
%arrayidx2 = getelementptr inbounds i16, ptr addrspace(1) %0, i32 18
231+
%arrayidx = addrspacecast ptr addrspace(1) %arrayidx2 to ptr
232+
%1 = load i16, ptr %arrayidx, align 2
233233
ret i16 %1
234234
}
235235

@@ -244,34 +244,34 @@ entry:
244244
; CHECK-NEXT: lg 1, 984(1)
245245
; CHECK-NEXT: iilf 0, 67240703
246246
; CHECK-NEXT: c 0, 80(1)
247-
%0 = load i8*** addrspace(1)*, i8*** addrspace(1)** inttoptr (i64 1208 to i8*** addrspace(1)**), align 8
248-
%arrayidx = getelementptr inbounds i8***, i8*** addrspace(1)* %0, i32 11
249-
%1 = load i8***, i8*** addrspace(1)* %arrayidx, align 8
250-
%arrayidx1 = getelementptr inbounds i8**, i8*** %1, i64 1
251-
%2 = load i8**, i8*** %arrayidx1, align 8
252-
%arrayidx2 = getelementptr inbounds i8*, i8** %2, i64 123
253-
%3 = load i8*, i8** %arrayidx2, align 8
254-
%add.ptr = getelementptr inbounds i8, i8* %3, i64 80
255-
%4 = bitcast i8* %add.ptr to i32*
256-
%5 = load i32, i32* %4, align 4
247+
%0 = load ptr addrspace(1), ptr inttoptr (i64 1208 to ptr), align 8
248+
%arrayidx = getelementptr inbounds ptr, ptr addrspace(1) %0, i32 11
249+
%1 = load ptr, ptr addrspace(1) %arrayidx, align 8
250+
%arrayidx1 = getelementptr inbounds ptr, ptr %1, i64 1
251+
%2 = load ptr, ptr %arrayidx1, align 8
252+
%arrayidx2 = getelementptr inbounds ptr, ptr %2, i64 123
253+
%3 = load ptr, ptr %arrayidx2, align 8
254+
%add.ptr = getelementptr inbounds i8, ptr %3, i64 80
255+
%4 = bitcast ptr %add.ptr to ptr
256+
%5 = load i32, ptr %4, align 4
257257
%cmp = icmp sgt i32 %5, 67240703
258258
%conv = zext i1 %cmp to i32
259259
ret i32 %conv
260260
}
261261

262-
define void @test_misc_5(%struct.Foo* %f) {
262+
define void @test_misc_5(ptr %f) {
263263
entry:
264264
; CHECK-LABEL: test_misc_5:
265265
; CHECK: l 0, 548
266266
; CHECK-NEXT: lg 6, 8(5)
267267
; CHECK-NEXT: lg 5, 0(5)
268268
; CHECK-NEXT: llgtr 0, 0
269269
; CHECK-NEXT: stg 0, 16(1)
270-
%0 = load i8 addrspace(1)*, i8 addrspace(1)** inttoptr (i64 548 to i8 addrspace(1)**), align 4
271-
%1 = addrspacecast i8 addrspace(1)* %0 to i8*
272-
%cp64 = getelementptr inbounds %struct.Foo, %struct.Foo* %f, i64 0, i32 2
273-
store i8* %1, i8** %cp64, align 8
274-
tail call void @use_foo(%struct.Foo* %f)
270+
%0 = load ptr addrspace(1), ptr inttoptr (i64 548 to ptr), align 4
271+
%1 = addrspacecast ptr addrspace(1) %0 to ptr
272+
%cp64 = getelementptr inbounds %struct.Foo, ptr %f, i64 0, i32 2
273+
store ptr %1, ptr %cp64, align 8
274+
tail call void @use_foo(ptr %f)
275275
ret void
276276
}
277277

@@ -285,11 +285,11 @@ entry:
285285
; CHECK-NEXT: a 0, 0(1)
286286
; CHECK-NEXT: llgtr 1, 0
287287
; CHECK-NEXT: lgb 3, 0(1)
288-
%0 = load i8 addrspace(1)* addrspace(1)*, i8 addrspace(1)* addrspace(1)** inttoptr (i64 16 to i8 addrspace(1)* addrspace(1)**), align 16
289-
%arrayidx = getelementptr inbounds i8 addrspace(1)*, i8 addrspace(1)* addrspace(1)* %0, i32 165
290-
%1 = load i8 addrspace(1)*, i8 addrspace(1)* addrspace(1)* %arrayidx, align 4
291-
%arrayidx1 = getelementptr inbounds i8, i8 addrspace(1)* %1, i32 53
292-
%2 = load i8, i8 addrspace(1)* %arrayidx1, align 1
288+
%0 = load ptr addrspace(1), ptr inttoptr (i64 16 to ptr), align 16
289+
%arrayidx = getelementptr inbounds ptr addrspace(1), ptr addrspace(1) %0, i32 165
290+
%1 = load ptr addrspace(1), ptr addrspace(1) %arrayidx, align 4
291+
%arrayidx1 = getelementptr inbounds i8, ptr addrspace(1) %1, i32 53
292+
%2 = load i8, ptr addrspace(1) %arrayidx1, align 1
293293
%conv = sext i8 %2 to i32
294294
ret i32 %conv
295295
}
@@ -312,10 +312,10 @@ entry:
312312
; CHECK-NEXT: lg 7, 2072(4)
313313
; CHECK-NEXT: aghi 4, 192
314314
; CHECK-NEXT: b 2(7)
315-
tail call void (i32, ...) @g(i32 noundef signext 5, i8 addrspace(1)* noundef %p, i8 addrspace(1)* noundef %p, i8 addrspace(1)* noundef %p, i8 addrspace(1)* noundef %p, i8 addrspace(1)* noundef %p)
316-
ret void
315+
tail call void (i32, ...) @g(i32 noundef signext 5, ptr addrspace(1) noundef %p, ptr addrspace(1) noundef %p, ptr addrspace(1) noundef %p, ptr addrspace(1) noundef %p, ptr addrspace(1) noundef %p)
316+
ret void
317317
}
318-
declare void @g(i32 noundef signext, ...)
318+
declare void @g(i32 signext, ...)
319319

320320
; The resulting instructions may look odd on first view but it is a result of
321321
; the C code. __malloc31() returns a 64 bit pointer, thus the sequence
@@ -336,12 +336,12 @@ define signext i32 @setlength() {
336336
; CHECK: llgtr [[ADDR]], [[ADDR]]
337337
; CHECK: stg [[LENGTH]], 0([[ADDR]])
338338
entry:
339-
%call = tail call i8* @__malloc31(i64 noundef 8)
340-
%call1 = tail call signext i32 bitcast (i32 (...)* @foo to i32 ()*)()
341-
%length = getelementptr inbounds i8, i8* %call, i64 4
342-
%0 = bitcast i8* %length to i32*
343-
%1 = addrspacecast i32* %0 to i32 addrspace(1)*
344-
store i32 %call1, i32 addrspace(1)* %1, align 4
339+
%call = tail call ptr @__malloc31(i64 noundef 8)
340+
%call1 = tail call signext i32 @foo()
341+
%length = getelementptr inbounds i8, ptr %call, i64 4
342+
%0 = bitcast ptr %length to ptr
343+
%1 = addrspacecast ptr %0 to ptr addrspace(1)
344+
store i32 %call1, ptr addrspace(1) %1, align 4
345345
ret i32 0
346346
}
347347

@@ -350,7 +350,7 @@ entry:
350350
; instead of __malloc31(). Note the different instruction sequence, because
351351
; the function now returns a __ptr32.
352352
;
353-
define hidden signext i32 @setlength2() {
353+
define signext i32 @setlength2() {
354354
; CHECK-LABEL: setlength2:
355355
; CHECK: basr 7, 6
356356
; CHECK: lgr [[MALLOC:[0-9]+]], 3
@@ -360,16 +360,16 @@ define hidden signext i32 @setlength2() {
360360
; CHECK: llgtr [[ADDR]], [[MALLOC]]
361361
; CHECK: stg [[LENGTH]], 0([[ADDR]])
362362
entry:
363-
%call = tail call i8 addrspace(1)* @domalloc(i64 noundef 8)
364-
%call1 = tail call signext i32 bitcast (i32 (...)* @foo to i32 ()*)() #2
365-
%length = getelementptr inbounds i8, i8 addrspace(1)* %call, i32 4
366-
%0 = bitcast i8 addrspace(1)* %length to i32 addrspace(1)*
367-
store i32 %call1, i32 addrspace(1)* %0, align 4
363+
%call = tail call ptr addrspace(1) @domalloc(i64 noundef 8)
364+
%call1 = tail call signext i32 @foo()
365+
%length = getelementptr inbounds i8, ptr addrspace(1) %call, i32 4
366+
%0 = bitcast ptr addrspace(1) %length to ptr addrspace(1)
367+
store i32 %call1, ptr addrspace(1) %0, align 4
368368
ret i32 0
369369
}
370370

371-
declare i8* @__malloc31(i64 noundef)
371+
declare ptr @__malloc31(i64)
372372

373373
declare signext i32 @foo(...)
374374

375-
declare i8 addrspace(1)* @domalloc(i64 noundef)
375+
declare ptr addrspace(1) @domalloc(i64)

0 commit comments

Comments
 (0)