aboutsummaryrefslogtreecommitdiffhomepage
path: root/compiler/testdata/slice.ll
blob: 29d5ed8a419d6dfe0039660f444f954ce866cce1 (plain)
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
; ModuleID = 'slice.go'
source_filename = "slice.go"
target datalayout = "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-n32:64-S128-ni:1:10:20"
target triple = "wasm32-unknown-wasi"

; Function Attrs: allockind("alloc,zeroed") allocsize(0)
declare noalias nonnull ptr @runtime.alloc(i32, ptr, ptr) #0

declare void @runtime.trackPointer(ptr nocapture readonly, ptr, ptr) #1

; Function Attrs: nounwind
define hidden void @main.init(ptr %context) unnamed_addr #2 {
entry:
  ret void
}

; Function Attrs: nounwind
define hidden i32 @main.sliceLen(ptr %ints.data, i32 %ints.len, i32 %ints.cap, ptr %context) unnamed_addr #2 {
entry:
  ret i32 %ints.len
}

; Function Attrs: nounwind
define hidden i32 @main.sliceCap(ptr %ints.data, i32 %ints.len, i32 %ints.cap, ptr %context) unnamed_addr #2 {
entry:
  ret i32 %ints.cap
}

; Function Attrs: nounwind
define hidden i32 @main.sliceElement(ptr %ints.data, i32 %ints.len, i32 %ints.cap, i32 %index, ptr %context) unnamed_addr #2 {
entry:
  %.not = icmp ult i32 %index, %ints.len
  br i1 %.not, label %lookup.next, label %lookup.throw

lookup.next:                                      ; preds = %entry
  %0 = getelementptr inbounds i32, ptr %ints.data, i32 %index
  %1 = load i32, ptr %0, align 4
  ret i32 %1

lookup.throw:                                     ; preds = %entry
  call void @runtime.lookupPanic(ptr undef) #3
  unreachable
}

declare void @runtime.lookupPanic(ptr) #1

; Function Attrs: nounwind
define hidden { ptr, i32, i32 } @main.sliceAppendValues(ptr %ints.data, i32 %ints.len, i32 %ints.cap, ptr %context) unnamed_addr #2 {
entry:
  %stackalloc = alloca i8, align 1
  %varargs = call dereferenceable(12) ptr @runtime.alloc(i32 12, ptr nonnull inttoptr (i32 3 to ptr), ptr undef) #3
  call void @runtime.trackPointer(ptr nonnull %varargs, ptr nonnull %stackalloc, ptr undef) #3
  store i32 1, ptr %varargs, align 4
  %0 = getelementptr inbounds [3 x i32], ptr %varargs, i32 0, i32 1
  store i32 2, ptr %0, align 4
  %1 = getelementptr inbounds [3 x i32], ptr %varargs, i32 0, i32 2
  store i32 3, ptr %1, align 4
  %append.new = call { ptr, i32, i32 } @runtime.sliceAppend(ptr %ints.data, ptr nonnull %varargs, i32 %ints.len, i32 %ints.cap, i32 3, i32 4, ptr undef) #3
  %append.newPtr = extractvalue { ptr, i32, i32 } %append.new, 0
  %append.newLen = extractvalue { ptr, i32, i32 } %append.new, 1
  %append.newCap = extractvalue { ptr, i32, i32 } %append.new, 2
  %2 = insertvalue { ptr, i32, i32 } undef, ptr %append.newPtr, 0
  %3 = insertvalue { ptr, i32, i32 } %2, i32 %append.newLen, 1
  %4 = insertvalue { ptr, i32, i32 } %3, i32 %append.newCap, 2
  call void @runtime.trackPointer(ptr %append.newPtr, ptr nonnull %stackalloc, ptr undef) #3
  ret { ptr, i32, i32 } %4
}

declare { ptr, i32, i32 } @runtime.sliceAppend(ptr, ptr nocapture readonly, i32, i32, i32, i32, ptr) #1

; Function Attrs: nounwind
define hidden { ptr, i32, i32 } @main.sliceAppendSlice(ptr %ints.data, i32 %ints.len, i32 %ints.cap, ptr %added.data, i32 %added.len, i32 %added.cap, ptr %context) unnamed_addr #2 {
entry:
  %stackalloc = alloca i8, align 1
  %append.new = call { ptr, i32, i32 } @runtime.sliceAppend(ptr %ints.data, ptr %added.data, i32 %ints.len, i32 %ints.cap, i32 %added.len, i32 4, ptr undef) #3
  %append.newPtr = extractvalue { ptr, i32, i32 } %append.new, 0
  %append.newLen = extractvalue { ptr, i32, i32 } %append.new, 1
  %append.newCap = extractvalue { ptr, i32, i32 } %append.new, 2
  %0 = insertvalue { ptr, i32, i32 } undef, ptr %append.newPtr, 0
  %1 = insertvalue { ptr, i32, i32 } %0, i32 %append.newLen, 1
  %2 = insertvalue { ptr, i32, i32 } %1, i32 %append.newCap, 2
  call void @runtime.trackPointer(ptr %append.newPtr, ptr nonnull %stackalloc, ptr undef) #3
  ret { ptr, i32, i32 } %2
}

; Function Attrs: nounwind
define hidden i32 @main.sliceCopy(ptr %dst.data, i32 %dst.len, i32 %dst.cap, ptr %src.data, i32 %src.len, i32 %src.cap, ptr %context) unnamed_addr #2 {
entry:
  %copy.n = call i32 @runtime.sliceCopy(ptr %dst.data, ptr %src.data, i32 %dst.len, i32 %src.len, i32 4, ptr undef) #3
  ret i32 %copy.n
}

declare i32 @runtime.sliceCopy(ptr nocapture writeonly, ptr nocapture readonly, i32, i32, i32, ptr) #1

; Function Attrs: nounwind
define hidden { ptr, i32, i32 } @main.makeByteSlice(i32 %len, ptr %context) unnamed_addr #2 {
entry:
  %stackalloc = alloca i8, align 1
  %slice.maxcap = icmp slt i32 %len, 0
  br i1 %slice.maxcap, label %slice.throw, label %slice.next

slice.next:                                       ; preds = %entry
  %makeslice.buf = call ptr @runtime.alloc(i32 %len, ptr nonnull inttoptr (i32 3 to ptr), ptr undef) #3
  %0 = insertvalue { ptr, i32, i32 } undef, ptr %makeslice.buf, 0
  %1 = insertvalue { ptr, i32, i32 } %0, i32 %len, 1
  %2 = insertvalue { ptr, i32, i32 } %1, i32 %len, 2
  call void @runtime.trackPointer(ptr nonnull %makeslice.buf, ptr nonnull %stackalloc, ptr undef) #3
  ret { ptr, i32, i32 } %2

slice.throw:                                      ; preds = %entry
  call void @runtime.slicePanic(ptr undef) #3
  unreachable
}

declare void @runtime.slicePanic(ptr) #1

; Function Attrs: nounwind
define hidden { ptr, i32, i32 } @main.makeInt16Slice(i32 %len, ptr %context) unnamed_addr #2 {
entry:
  %stackalloc = alloca i8, align 1
  %slice.maxcap = icmp slt i32 %len, 0
  br i1 %slice.maxcap, label %slice.throw, label %slice.next

slice.next:                                       ; preds = %entry
  %makeslice.cap = shl nuw i32 %len, 1
  %makeslice.buf = call ptr @runtime.alloc(i32 %makeslice.cap, ptr nonnull inttoptr (i32 3 to ptr), ptr undef) #3
  %0 = insertvalue { ptr, i32, i32 } undef, ptr %makeslice.buf, 0
  %1 = insertvalue { ptr, i32, i32 } %0, i32 %len, 1
  %2 = insertvalue { ptr, i32, i32 } %1, i32 %len, 2
  call void @runtime.trackPointer(ptr nonnull %makeslice.buf, ptr nonnull %stackalloc, ptr undef) #3
  ret { ptr, i32, i32 } %2

slice.throw:                                      ; preds = %entry
  call void @runtime.slicePanic(ptr undef) #3
  unreachable
}

; Function Attrs: nounwind
define hidden { ptr, i32, i32 } @main.makeArraySlice(i32 %len, ptr %context) unnamed_addr #2 {
entry:
  %stackalloc = alloca i8, align 1
  %slice.maxcap = icmp ugt i32 %len, 1431655765
  br i1 %slice.maxcap, label %slice.throw, label %slice.next

slice.next:                                       ; preds = %entry
  %makeslice.cap = mul i32 %len, 3
  %makeslice.buf = call ptr @runtime.alloc(i32 %makeslice.cap, ptr nonnull inttoptr (i32 3 to ptr), ptr undef) #3
  %0 = insertvalue { ptr, i32, i32 } undef, ptr %makeslice.buf, 0
  %1 = insertvalue { ptr, i32, i32 } %0, i32 %len, 1
  %2 = insertvalue { ptr, i32, i32 } %1, i32 %len, 2
  call void @runtime.trackPointer(ptr nonnull %makeslice.buf, ptr nonnull %stackalloc, ptr undef) #3
  ret { ptr, i32, i32 } %2

slice.throw:                                      ; preds = %entry
  call void @runtime.slicePanic(ptr undef) #3
  unreachable
}

; Function Attrs: nounwind
define hidden { ptr, i32, i32 } @main.makeInt32Slice(i32 %len, ptr %context) unnamed_addr #2 {
entry:
  %stackalloc = alloca i8, align 1
  %slice.maxcap = icmp ugt i32 %len, 1073741823
  br i1 %slice.maxcap, label %slice.throw, label %slice.next

slice.next:                                       ; preds = %entry
  %makeslice.cap = shl nuw i32 %len, 2
  %makeslice.buf = call ptr @runtime.alloc(i32 %makeslice.cap, ptr nonnull inttoptr (i32 3 to ptr), ptr undef) #3
  %0 = insertvalue { ptr, i32, i32 } undef, ptr %makeslice.buf, 0
  %1 = insertvalue { ptr, i32, i32 } %0, i32 %len, 1
  %2 = insertvalue { ptr, i32, i32 } %1, i32 %len, 2
  call void @runtime.trackPointer(ptr nonnull %makeslice.buf, ptr nonnull %stackalloc, ptr undef) #3
  ret { ptr, i32, i32 } %2

slice.throw:                                      ; preds = %entry
  call void @runtime.slicePanic(ptr undef) #3
  unreachable
}

; Function Attrs: nounwind
define hidden ptr @main.Add32(ptr %p, i32 %len, ptr %context) unnamed_addr #2 {
entry:
  %stackalloc = alloca i8, align 1
  %0 = getelementptr i8, ptr %p, i32 %len
  call void @runtime.trackPointer(ptr %0, ptr nonnull %stackalloc, ptr undef) #3
  ret ptr %0
}

; Function Attrs: nounwind
define hidden ptr @main.Add64(ptr %p, i64 %len, ptr %context) unnamed_addr #2 {
entry:
  %stackalloc = alloca i8, align 1
  %0 = trunc i64 %len to i32
  %1 = getelementptr i8, ptr %p, i32 %0
  call void @runtime.trackPointer(ptr %1, ptr nonnull %stackalloc, ptr undef) #3
  ret ptr %1
}

; Function Attrs: nounwind
define hidden ptr @main.SliceToArray(ptr %s.data, i32 %s.len, i32 %s.cap, ptr %context) unnamed_addr #2 {
entry:
  %0 = icmp ult i32 %s.len, 4
  br i1 %0, label %slicetoarray.throw, label %slicetoarray.next

slicetoarray.next:                                ; preds = %entry
  ret ptr %s.data

slicetoarray.throw:                               ; preds = %entry
  call void @runtime.sliceToArrayPointerPanic(ptr undef) #3
  unreachable
}

declare void @runtime.sliceToArrayPointerPanic(ptr) #1

; Function Attrs: nounwind
define hidden ptr @main.SliceToArrayConst(ptr %context) unnamed_addr #2 {
entry:
  %stackalloc = alloca i8, align 1
  %makeslice = call dereferenceable(24) ptr @runtime.alloc(i32 24, ptr nonnull inttoptr (i32 3 to ptr), ptr undef) #3
  call void @runtime.trackPointer(ptr nonnull %makeslice, ptr nonnull %stackalloc, ptr undef) #3
  br i1 false, label %slicetoarray.throw, label %slicetoarray.next

slicetoarray.next:                                ; preds = %entry
  ret ptr %makeslice

slicetoarray.throw:                               ; preds = %entry
  unreachable
}

; Function Attrs: nounwind
define hidden { ptr, i32, i32 } @main.SliceInt(ptr dereferenceable_or_null(4) %ptr, i32 %len, ptr %context) unnamed_addr #2 {
entry:
  %stackalloc = alloca i8, align 1
  %0 = icmp ugt i32 %len, 1073741823
  %1 = icmp eq ptr %ptr, null
  %2 = icmp ne i32 %len, 0
  %3 = and i1 %1, %2
  %4 = or i1 %3, %0
  br i1 %4, label %unsafe.Slice.throw, label %unsafe.Slice.next

unsafe.Slice.next:                                ; preds = %entry
  %5 = insertvalue { ptr, i32, i32 } undef, ptr %ptr, 0
  %6 = insertvalue { ptr, i32, i32 } %5, i32 %len, 1
  %7 = insertvalue { ptr, i32, i32 } %6, i32 %len, 2
  call void @runtime.trackPointer(ptr %ptr, ptr nonnull %stackalloc, ptr undef) #3
  ret { ptr, i32, i32 } %7

unsafe.Slice.throw:                               ; preds = %entry
  call void @runtime.unsafeSlicePanic(ptr undef) #3
  unreachable
}

declare void @runtime.unsafeSlicePanic(ptr) #1

; Function Attrs: nounwind
define hidden { ptr, i32, i32 } @main.SliceUint16(ptr dereferenceable_or_null(1) %ptr, i16 %len, ptr %context) unnamed_addr #2 {
entry:
  %stackalloc = alloca i8, align 1
  %0 = icmp eq ptr %ptr, null
  %1 = icmp ne i16 %len, 0
  %2 = and i1 %0, %1
  br i1 %2, label %unsafe.Slice.throw, label %unsafe.Slice.next

unsafe.Slice.next:                                ; preds = %entry
  %3 = zext i16 %len to i32
  %4 = insertvalue { ptr, i32, i32 } undef, ptr %ptr, 0
  %5 = insertvalue { ptr, i32, i32 } %4, i32 %3, 1
  %6 = insertvalue { ptr, i32, i32 } %5, i32 %3, 2
  call void @runtime.trackPointer(ptr %ptr, ptr nonnull %stackalloc, ptr undef) #3
  ret { ptr, i32, i32 } %6

unsafe.Slice.throw:                               ; preds = %entry
  call void @runtime.unsafeSlicePanic(ptr undef) #3
  unreachable
}

; Function Attrs: nounwind
define hidden { ptr, i32, i32 } @main.SliceUint64(ptr dereferenceable_or_null(4) %ptr, i64 %len, ptr %context) unnamed_addr #2 {
entry:
  %stackalloc = alloca i8, align 1
  %0 = icmp ugt i64 %len, 1073741823
  %1 = icmp eq ptr %ptr, null
  %2 = icmp ne i64 %len, 0
  %3 = and i1 %1, %2
  %4 = or i1 %3, %0
  br i1 %4, label %unsafe.Slice.throw, label %unsafe.Slice.next

unsafe.Slice.next:                                ; preds = %entry
  %5 = trunc i64 %len to i32
  %6 = insertvalue { ptr, i32, i32 } undef, ptr %ptr, 0
  %7 = insertvalue { ptr, i32, i32 } %6, i32 %5, 1
  %8 = insertvalue { ptr, i32, i32 } %7, i32 %5, 2
  call void @runtime.trackPointer(ptr %ptr, ptr nonnull %stackalloc, ptr undef) #3
  ret { ptr, i32, i32 } %8

unsafe.Slice.throw:                               ; preds = %entry
  call void @runtime.unsafeSlicePanic(ptr undef) #3
  unreachable
}

; Function Attrs: nounwind
define hidden { ptr, i32, i32 } @main.SliceInt64(ptr dereferenceable_or_null(4) %ptr, i64 %len, ptr %context) unnamed_addr #2 {
entry:
  %stackalloc = alloca i8, align 1
  %0 = icmp ugt i64 %len, 1073741823
  %1 = icmp eq ptr %ptr, null
  %2 = icmp ne i64 %len, 0
  %3 = and i1 %1, %2
  %4 = or i1 %3, %0
  br i1 %4, label %unsafe.Slice.throw, label %unsafe.Slice.next

unsafe.Slice.next:                                ; preds = %entry
  %5 = trunc i64 %len to i32
  %6 = insertvalue { ptr, i32, i32 } undef, ptr %ptr, 0
  %7 = insertvalue { ptr, i32, i32 } %6, i32 %5, 1
  %8 = insertvalue { ptr, i32, i32 } %7, i32 %5, 2
  call void @runtime.trackPointer(ptr %ptr, ptr nonnull %stackalloc, ptr undef) #3
  ret { ptr, i32, i32 } %8

unsafe.Slice.throw:                               ; preds = %entry
  call void @runtime.unsafeSlicePanic(ptr undef) #3
  unreachable
}

attributes #0 = { allockind("alloc,zeroed") allocsize(0) "alloc-family"="runtime.alloc" "target-features"="+bulk-memory,+mutable-globals,+nontrapping-fptoint,+sign-ext" }
attributes #1 = { "target-features"="+bulk-memory,+mutable-globals,+nontrapping-fptoint,+sign-ext" }
attributes #2 = { nounwind "target-features"="+bulk-memory,+mutable-globals,+nontrapping-fptoint,+sign-ext" }
attributes #3 = { nounwind }