File: sroa.sil

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (438 lines) | stat: -rw-r--r-- 23,331 bytes parent folder | download
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
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
// RUN: %target-sil-opt -enable-sil-verify-all -sroa %s | %FileCheck %s

sil_stage canonical

import Builtin
import Swift

///////////////////////////////
// Struct with Scalar Fields //
///////////////////////////////

struct S1 {
  var x : Builtin.Int1
  var y : Builtin.Int32
  var z : Builtin.Int64
}

sil @use_int32 : $@convention(thin) (Builtin.Int32) -> ()

// CHECK-LABEL: sil @struct_with_scalar_fields : $@convention(thin) (S1) -> ()
// CHECK: bb0([[VAR_0:%[0-9]+]] : $S1):
// CHECK:   [[VAR_1:%[0-9]+]] = alloc_stack $Builtin.Int1
// CHECK:   [[VAR_2:%[0-9]+]] = alloc_stack $Builtin.Int32
// CHECK:   [[VAR_3:%[0-9]+]] = alloc_stack $Builtin.Int64
// CHECK:   [[VAR_4:%[0-9]+]] = struct_extract [[VAR_0]] : $S1, #S1.x
// CHECK:   [[VAR_6:%[0-9]+]] = struct_extract [[VAR_0]] : $S1, #S1.y
// CHECK:   [[VAR_8:%[0-9]+]] = struct_extract [[VAR_0]] : $S1, #S1.z
// CHECK:   store [[VAR_4]] to [[VAR_1]] : $*Builtin.Int1
// CHECK:   store [[VAR_6]] to [[VAR_2]] : $*Builtin.Int32
// CHECK:   store [[VAR_8]] to [[VAR_3]] : $*Builtin.Int64
// CHECK:   [[VAR_10:%[0-9]+]] = function_ref @use_int32 : $@convention(thin) (Builtin.Int32) -> ()
// CHECK:   [[VAR_11:%[0-9]+]] = load [[VAR_2]] : $*Builtin.Int32
// CHECK:   [[VAR_12:%[0-9]+]] = apply [[VAR_10]]([[VAR_11]]) : $@convention(thin) (Builtin.Int32) -> ()
// CHECK:   [[VAR_13:%[0-9]+]] = load [[VAR_1]] : $*Builtin.Int1
// CHECK:   [[VAR_14:%[0-9]+]] = load [[VAR_2]] : $*Builtin.Int32
// CHECK:   [[VAR_15:%[0-9]+]] = load [[VAR_3]] : $*Builtin.Int64
// CHECK:   [[VAR_16:%[0-9]+]] = struct $S1 ([[VAR_13]] : $Builtin.Int1, [[VAR_14]] : $Builtin.Int32, [[VAR_15]] : $Builtin.Int64)
// CHECK:   dealloc_stack [[VAR_3]] : $*Builtin.Int64
// CHECK:   dealloc_stack [[VAR_2]] : $*Builtin.Int32
// CHECK:   dealloc_stack [[VAR_1]] : $*Builtin.Int1
// CHECK:   [[VAR_20:%[0-9]+]] = tuple ()
// CHECK:   return [[VAR_20]] : $()
sil @struct_with_scalar_fields : $@convention(thin) (S1) -> () {
bb0(%0 : $S1):
  %1 = alloc_stack $S1
  store %0 to %1 : $*S1
  %2 = function_ref @use_int32 : $@convention(thin) (Builtin.Int32) -> ()
  %3 = struct_element_addr %1 : $*S1, #S1.y
  %4 = load %3 : $*Builtin.Int32
  apply %2(%4) : $@convention(thin) (Builtin.Int32) -> ()
  %5 = load %1 : $*S1
  dealloc_stack %1 : $*S1
  %6 = tuple ()
  return %6 : $()
}

// CHECK-LABEL: sil @dont_sroa_without_benefit : $@convention(thin) (S1) -> S1
// CHECK:      bb0
// CHECK-NEXT:   alloc_stack $S1
// CHECK-NEXT:   store %0 to %1 : $*S1
// CHECK-NEXT:   load %1 : $*S1
// CHECK-NEXT:   dealloc_stack %1 : $*S1
// CHECK-NEXT:   return
sil @dont_sroa_without_benefit : $@convention(thin) (S1) -> S1 {
bb0(%0 : $S1):
  %1 = alloc_stack $S1
  store %0 to %1 : $*S1
  %3 = load %1 : $*S1
  dealloc_stack %1 : $*S1
  return %3 : $S1
}


///////////////////////////////
// Struct With Struct Fields //
///////////////////////////////

sil @use_s1 : $@convention(thin) (S1) -> ()

struct S2 {
  var alpha : Builtin.FPIEEE32
  var beta : S1
}

// CHECK-LABEL: sil @struct_with_struct_fields : $@convention(thin) (S2, Builtin.Int64) -> ()
// CHECK: bb0([[VAR_0:%[0-9]+]] : $S2, [[VAR_1:%[0-9]+]] : $Builtin.Int64):
// CHECK:   [[VAR_2:%[0-9]+]] = alloc_stack $Builtin.FPIEEE32
// CHECK:   [[VAR_3:%[0-9]+]] = alloc_stack $Builtin.Int1
// CHECK:   [[VAR_4:%[0-9]+]] = alloc_stack $Builtin.Int32
// CHECK:   [[VAR_5:%[0-9]+]] = alloc_stack $Builtin.Int64
// CHECK:   [[VAR_6:%[0-9]+]] = struct_extract [[VAR_0]] : $S2, #S2.alpha
// CHECK:   [[VAR_8:%[0-9]+]] = struct_extract [[VAR_0]] : $S2, #S2.beta
// CHECK:   store [[VAR_6]] to [[VAR_2]] : $*Builtin.FPIEEE32
// CHECK:   [[VAR_9:%[0-9]+]] = struct_extract [[VAR_8]] : $S1, #S1.x
// CHECK:   [[VAR_11:%[0-9]+]] = struct_extract [[VAR_8]] : $S1, #S1.y
// CHECK:   [[VAR_13:%[0-9]+]] = struct_extract [[VAR_8]] : $S1, #S1.z
// CHECK:   store [[VAR_9]] to [[VAR_3]] : $*Builtin.Int1
// CHECK:   store [[VAR_11]] to [[VAR_4]] : $*Builtin.Int32
// CHECK:   store [[VAR_13]] to [[VAR_5]] : $*Builtin.Int64
// CHECK:   [[VAR_15:%[0-9]+]] = load [[VAR_3]] : $*Builtin.Int1
// CHECK:   [[VAR_16:%[0-9]+]] = load [[VAR_4]] : $*Builtin.Int32
// CHECK:   [[VAR_17:%[0-9]+]] = load [[VAR_5]] : $*Builtin.Int64
// CHECK:   [[VAR_18:%[0-9]+]] = struct $S1 ([[VAR_15]] : $Builtin.Int1, [[VAR_16]] : $Builtin.Int32, [[VAR_17]] : $Builtin.Int64)
// CHECK:   [[VAR_19:%[0-9]+]] = function_ref @use_s1 : $@convention(thin) (S1) -> ()
// CHECK:   [[VAR_20:%[0-9]+]] = apply [[VAR_19]]([[VAR_18]]) : $@convention(thin) (S1) -> ()
// CHECK:   [[VAR_21:%[0-9]+]] = function_ref @use_int32 : $@convention(thin) (Builtin.Int32) -> ()
// CHECK:   [[VAR_22:%[0-9]+]] = load [[VAR_4]] : $*Builtin.Int32
// CHECK:   [[VAR_23:%[0-9]+]] = apply [[VAR_21]]([[VAR_22]]) : $@convention(thin) (Builtin.Int32) -> ()
// CHECK:   [[VAR_24:%[0-9]+]] = load [[VAR_2]] : $*Builtin.FPIEEE32
// CHECK:   [[VAR_25:%[0-9]+]] = load [[VAR_3]] : $*Builtin.Int1
// CHECK:   [[VAR_26:%[0-9]+]] = load [[VAR_4]] : $*Builtin.Int32
// CHECK:   [[VAR_27:%[0-9]+]] = load [[VAR_5]] : $*Builtin.Int64
// CHECK:   [[VAR_28:%[0-9]+]] = struct $S1 ([[VAR_25]] : $Builtin.Int1, [[VAR_26]] : $Builtin.Int32, [[VAR_27]] : $Builtin.Int64)
// CHECK:   [[VAR_29:%[0-9]+]] = struct $S2 ([[VAR_24]] : $Builtin.FPIEEE32, [[VAR_28]] : $S1)
// CHECK:   store [[VAR_1]] to [[VAR_5]] : $*Builtin.Int64
// CHECK:   dealloc_stack [[VAR_5]] : $*Builtin.Int64
// CHECK:   dealloc_stack [[VAR_4]] : $*Builtin.Int32
// CHECK:   dealloc_stack [[VAR_3]] : $*Builtin.Int1
// CHECK:   dealloc_stack [[VAR_2]] : $*Builtin.FPIEEE32
// CHECK:   [[VAR_35:%[0-9]+]] = tuple ()
// CHECK:   return [[VAR_35]] : $()
sil @struct_with_struct_fields : $@convention(thin) (S2, Builtin.Int64) -> () {
bb0(%0 : $S2, %1 : $Builtin.Int64):
  %2 = alloc_stack $S2
  store %0 to %2 : $*S2
  %3 = struct_element_addr %2 : $*S2, #S2.beta
  %4 = load %3 : $*S1
  %5 = function_ref @use_s1 : $@convention(thin) (S1) -> ()
  apply %5(%4) : $@convention(thin) (S1) -> ()
  %6 = struct_element_addr %3 : $*S1, #S1.y
  %7 = function_ref @use_int32 : $@convention(thin) (Builtin.Int32) -> ()
  %8 = load %6 : $*Builtin.Int32
  apply %7(%8) : $@convention(thin) (Builtin.Int32) -> ()
  %9 = load %2 : $*S2
  %10 = struct_element_addr %3 : $*S1, #S1.z
  store %1 to %10 : $*Builtin.Int64
  dealloc_stack %2 : $*S2
  %11 = tuple()
  return %11 : $()
}

//////////////////////////////
// Struct with Tuple Fields //
//////////////////////////////

sil @use_tup : $@convention(thin) ((Builtin.Int32, Builtin.Int64, Builtin.Int16)) -> ()

struct S3 {
  var gamma : (Builtin.Int32, Builtin.Int64, Builtin.Int16)
  var delta : Builtin.FPIEEE32
}

// CHECK-LABEL: sil @struct_with_tuple_fields : $@convention(thin) (S3, Builtin.Int64) -> ()
// CHECK: bb0([[VAR_0:%[0-9]+]] : $S3, [[VAR_1:%[0-9]+]] : $Builtin.Int64):
// CHECK:   [[VAR_2:%[0-9]+]] = alloc_stack $Builtin.Int32
// CHECK:   [[VAR_3:%[0-9]+]] = alloc_stack $Builtin.Int64
// CHECK:   [[VAR_4:%[0-9]+]] = alloc_stack $Builtin.Int16
// CHECK:   [[VAR_5:%[0-9]+]] = alloc_stack $Builtin.FPIEEE32
// CHECK:   [[VAR_6:%[0-9]+]] = struct_extract [[VAR_0]] : $S3, #S3.gamma
// CHECK:   [[VAR_13:%[0-9]+]] = struct_extract [[VAR_0]] : $S3, #S3.delta
// CHECK:   [[VAR_7:%[0-9]+]] = tuple_extract [[VAR_6]] : $(Builtin.Int32, Builtin.Int64, Builtin.Int16), 0
// CHECK:   [[VAR_9:%[0-9]+]] = tuple_extract [[VAR_6]] : $(Builtin.Int32, Builtin.Int64, Builtin.Int16), 1
// CHECK:   [[VAR_11:%[0-9]+]] = tuple_extract [[VAR_6]] : $(Builtin.Int32, Builtin.Int64, Builtin.Int16), 2
// CHECK:   store [[VAR_7]] to [[VAR_2]] : $*Builtin.Int32
// CHECK:   store [[VAR_9]] to [[VAR_3]] : $*Builtin.Int64
// CHECK:   store [[VAR_11]] to [[VAR_4]] : $*Builtin.Int16
// CHECK:   store [[VAR_13]] to [[VAR_5]] : $*Builtin.FPIEEE32
// CHECK:   [[VAR_15:%[0-9]+]] = function_ref @use_tup : $@convention(thin) ((Builtin.Int32, Builtin.Int64, Builtin.Int16)) -> ()
// CHECK:   [[VAR_16:%[0-9]+]] = load [[VAR_2]] : $*Builtin.Int32
// CHECK:   [[VAR_17:%[0-9]+]] = load [[VAR_3]] : $*Builtin.Int64
// CHECK:   [[VAR_18:%[0-9]+]] = load [[VAR_4]] : $*Builtin.Int16
// CHECK:   [[VAR_19:%[0-9]+]] = tuple ([[VAR_16]] : $Builtin.Int32, [[VAR_17]] : $Builtin.Int64, [[VAR_18]] : $Builtin.Int16)
// CHECK:   [[VAR_20:%[0-9]+]] = apply [[VAR_15]]([[VAR_19]]) : $@convention(thin) ((Builtin.Int32, Builtin.Int64, Builtin.Int16)) -> ()
// CHECK:   [[VAR_21:%[0-9]+]] = load [[VAR_2]] : $*Builtin.Int32
// CHECK:   [[VAR_22:%[0-9]+]] = function_ref @use_int32 : $@convention(thin) (Builtin.Int32) -> ()
// CHECK:   [[VAR_23:%[0-9]+]] = apply [[VAR_22]]([[VAR_21]]) : $@convention(thin) (Builtin.Int32) -> ()
// CHECK:   [[VAR_24:%[0-9]+]] = load [[VAR_2]] : $*Builtin.Int32
// CHECK:   [[VAR_25:%[0-9]+]] = load [[VAR_3]] : $*Builtin.Int64
// CHECK:   [[VAR_26:%[0-9]+]] = load [[VAR_4]] : $*Builtin.Int16
// CHECK:   [[VAR_27:%[0-9]+]] = tuple ([[VAR_24]] : $Builtin.Int32, [[VAR_25]] : $Builtin.Int64, [[VAR_26]] : $Builtin.Int16)
// CHECK:   [[VAR_28:%[0-9]+]] = load [[VAR_5]] : $*Builtin.FPIEEE32
// CHECK:   [[VAR_29:%[0-9]+]] = struct $S3 ([[VAR_27]] : $(Builtin.Int32, Builtin.Int64, Builtin.Int16), [[VAR_28]] : $Builtin.FPIEEE32)
// CHECK:   store [[VAR_1]] to [[VAR_3]] : $*Builtin.Int64
// CHECK:   dealloc_stack [[VAR_5]] : $*Builtin.FPIEEE32
// CHECK:   dealloc_stack [[VAR_4]] : $*Builtin.Int16
// CHECK:   dealloc_stack [[VAR_3]] : $*Builtin.Int64
// CHECK:   dealloc_stack [[VAR_2]] : $*Builtin.Int32
// CHECK:   [[VAR_35:%[0-9]+]] = tuple ()
// CHECK:   return [[VAR_35]] : $()
sil @struct_with_tuple_fields : $@convention(thin) (S3, Builtin.Int64) -> () {
bb0(%0 : $S3, %1 : $Builtin.Int64):
  %2 = alloc_stack $S3
  store %0 to %2 : $*S3
  %3 = function_ref @use_tup : $@convention(thin) ((Builtin.Int32, Builtin.Int64, Builtin.Int16)) -> ()
  %4 = struct_element_addr %2 : $*S3, #S3.gamma
  %5 = load %4 : $*(Builtin.Int32, Builtin.Int64, Builtin.Int16)
  apply %3(%5) : $@convention(thin) ((Builtin.Int32, Builtin.Int64, Builtin.Int16)) -> ()
  %6 = tuple_element_addr %4 : $*(Builtin.Int32, Builtin.Int64, Builtin.Int16), 0
  %7 = load %6 : $*Builtin.Int32
  %8 = function_ref @use_int32 : $@convention(thin) (Builtin.Int32) -> ()
  apply %8(%7) : $@convention(thin) (Builtin.Int32) -> ()
  %9 = load %2 : $*S3
  %10 = tuple_element_addr %4 : $*(Builtin.Int32, Builtin.Int64, Builtin.Int16), 1
  store %1 to %10 : $*Builtin.Int64
  dealloc_stack %2 : $*S3
  %11 = tuple ()
  return %11 : $()
}

//////////////////////////////
// Tuple with Scalar Fields //
//////////////////////////////

// CHECK-LABEL: sil @tuple_with_scalar_fields : $@convention(thin) ((Builtin.Int1, Builtin.Int32, Builtin.Int64)) -> ()
// CHECK: bb0([[VAR_0:%[0-9]+]] : $(Builtin.Int1, Builtin.Int32, Builtin.Int64)):
// CHECK:   [[VAR_1:%[0-9]+]] = alloc_stack $Builtin.Int1
// CHECK:   [[VAR_2:%[0-9]+]] = alloc_stack $Builtin.Int32
// CHECK:   [[VAR_3:%[0-9]+]] = alloc_stack $Builtin.Int64
// CHECK:   [[VAR_4:%[0-9]+]] = tuple_extract [[VAR_0]] : $(Builtin.Int1, Builtin.Int32, Builtin.Int64), 0
// CHECK:   [[VAR_6:%[0-9]+]] = tuple_extract [[VAR_0]] : $(Builtin.Int1, Builtin.Int32, Builtin.Int64), 1
// CHECK:   [[VAR_8:%[0-9]+]] = tuple_extract [[VAR_0]] : $(Builtin.Int1, Builtin.Int32, Builtin.Int64), 2
// CHECK:   store [[VAR_4]] to [[VAR_1]] : $*Builtin.Int1
// CHECK:   store [[VAR_6]] to [[VAR_2]] : $*Builtin.Int32
// CHECK:   store [[VAR_8]] to [[VAR_3]] : $*Builtin.Int64
// CHECK:   [[VAR_10:%[0-9]+]] = function_ref @use_int32 : $@convention(thin) (Builtin.Int32) -> ()
// CHECK:   [[VAR_11:%[0-9]+]] = load [[VAR_2]] : $*Builtin.Int32
// CHECK:   [[VAR_12:%[0-9]+]] = apply [[VAR_10]]([[VAR_11]]) : $@convention(thin) (Builtin.Int32) -> ()
// CHECK:   [[VAR_13:%[0-9]+]] = load [[VAR_1]] : $*Builtin.Int1
// CHECK:   [[VAR_14:%[0-9]+]] = load [[VAR_2]] : $*Builtin.Int32
// CHECK:   [[VAR_15:%[0-9]+]] = load [[VAR_3]] : $*Builtin.Int64
// CHECK:   [[VAR_16:%[0-9]+]] = tuple ([[VAR_13]] : $Builtin.Int1, [[VAR_14]] : $Builtin.Int32, [[VAR_15]] : $Builtin.Int64)
// CHECK:   dealloc_stack [[VAR_3]] : $*Builtin.Int64
// CHECK:   dealloc_stack [[VAR_2]] : $*Builtin.Int32
// CHECK:   dealloc_stack [[VAR_1]] : $*Builtin.Int1
// CHECK:   [[VAR_20:%[0-9]+]] = tuple ()
// CHECK:   return [[VAR_20]] : $()
sil @tuple_with_scalar_fields : $@convention(thin) ((Builtin.Int1, Builtin.Int32, Builtin.Int64)) -> () {
bb0(%0 : $(Builtin.Int1, Builtin.Int32, Builtin.Int64)):
  %1 = alloc_stack $(Builtin.Int1, Builtin.Int32, Builtin.Int64)
  store %0 to %1 : $*(Builtin.Int1, Builtin.Int32, Builtin.Int64)
  %2 = function_ref @use_int32 : $@convention(thin) (Builtin.Int32) -> ()
  %3 = tuple_element_addr %1 : $*(Builtin.Int1, Builtin.Int32, Builtin.Int64), 1
  %4 = load %3 : $*Builtin.Int32
  apply %2(%4) : $@convention(thin) (Builtin.Int32) -> ()
  %5 = load %1 : $*(Builtin.Int1, Builtin.Int32, Builtin.Int64)
  dealloc_stack %1 : $*(Builtin.Int1, Builtin.Int32, Builtin.Int64)
  %6 = tuple()
  return %6 : $()
}

//////////////////////////////
// Tuple With Struct Fields //
//////////////////////////////

struct S4 {
  var aleph : Builtin.Int64
  var bet : Builtin.Int32
}

sil @use_str4 : $@convention(thin) (S4) -> ()

// CHECK-LABEL: sil @tuple_with_struct_fields : $@convention(thin) ((S4, Builtin.Int16), Builtin.Int16) -> ()
// CHECK: bb0([[VAR_0:%[0-9]+]] : $(S4, Builtin.Int16), [[VAR_1:%[0-9]+]] : $Builtin.Int16):
// CHECK:   [[VAR_2:%[0-9]+]] = alloc_stack $Builtin.Int64
// CHECK:   [[VAR_3:%[0-9]+]] = alloc_stack $Builtin.Int32
// CHECK:   [[VAR_4:%[0-9]+]] = alloc_stack $Builtin.Int16
// CHECK:   [[VAR_5:%[0-9]+]] = tuple_extract [[VAR_0]] : $(S4, Builtin.Int16), 0
// CHECK:   [[VAR_10:%[0-9]+]] = tuple_extract [[VAR_0]] : $(S4, Builtin.Int16), 1
// CHECK:   [[VAR_6:%[0-9]+]] = struct_extract [[VAR_5]] : $S4, #S4.aleph
// CHECK:   [[VAR_8:%[0-9]+]] = struct_extract [[VAR_5]] : $S4, #S4.bet
// CHECK:   store [[VAR_6]] to [[VAR_2]] : $*Builtin.Int64
// CHECK:   store [[VAR_8]] to [[VAR_3]] : $*Builtin.Int32
// CHECK:   store [[VAR_10]] to [[VAR_4]] : $*Builtin.Int16
// CHECK:   [[VAR_12:%[0-9]+]] = function_ref @use_str4 : $@convention(thin) (S4) -> ()
// CHECK:   [[VAR_13:%[0-9]+]] = load [[VAR_2]] : $*Builtin.Int64
// CHECK:   [[VAR_14:%[0-9]+]] = load [[VAR_3]] : $*Builtin.Int32
// CHECK:   [[VAR_15:%[0-9]+]] = struct $S4 ([[VAR_13]] : $Builtin.Int64, [[VAR_14]] : $Builtin.Int32)
// CHECK:   [[VAR_16:%[0-9]+]] = apply [[VAR_12]]([[VAR_15]]) : $@convention(thin) (S4) -> ()
// CHECK:   [[VAR_17:%[0-9]+]] = load [[VAR_3]] : $*Builtin.Int32
// CHECK:   [[VAR_18:%[0-9]+]] = function_ref @use_int32 : $@convention(thin) (Builtin.Int32) -> ()
// CHECK:   [[VAR_19:%[0-9]+]] = apply [[VAR_18]]([[VAR_17]]) : $@convention(thin) (Builtin.Int32) -> ()
// CHECK:   [[VAR_20:%[0-9]+]] = load [[VAR_2]] : $*Builtin.Int64
// CHECK:   [[VAR_21:%[0-9]+]] = load [[VAR_3]] : $*Builtin.Int32
// CHECK:   [[VAR_22:%[0-9]+]] = struct $S4 ([[VAR_20]] : $Builtin.Int64, [[VAR_21]] : $Builtin.Int32)
// CHECK:   [[VAR_23:%[0-9]+]] = load [[VAR_4]] : $*Builtin.Int16
// CHECK:   [[VAR_24:%[0-9]+]] = tuple ([[VAR_22]] : $S4, [[VAR_23]] : $Builtin.Int16)
// CHECK:   store [[VAR_1]] to [[VAR_4]] : $*Builtin.Int16
// CHECK:   dealloc_stack [[VAR_4]] : $*Builtin.Int16
// CHECK:   dealloc_stack [[VAR_3]] : $*Builtin.Int32
// CHECK:   dealloc_stack [[VAR_2]] : $*Builtin.Int64
// CHECK:   [[VAR_29:%[0-9]+]] = tuple ()
// CHECK:   return [[VAR_29]] : $()
sil @tuple_with_struct_fields : $@convention(thin) ((S4, Builtin.Int16), Builtin.Int16) -> () {
bb0(%0 : $(S4, Builtin.Int16), %1 : $Builtin.Int16):
  %2 = alloc_stack $(S4, Builtin.Int16)
  store %0 to %2 : $*(S4, Builtin.Int16)
  %3 = function_ref @use_str4 : $@convention(thin) (S4) -> ()
  %4 = tuple_element_addr %2 : $*(S4, Builtin.Int16), 0
  %5 = load %4 : $*S4
  apply %3(%5) : $@convention(thin) (S4) -> ()
  %6 = struct_element_addr %4 : $*S4, #S4.bet
  %7 = load %6 : $*Builtin.Int32
  %8 = function_ref @use_int32 : $@convention(thin) (Builtin.Int32) -> ()
  apply %8(%7) : $@convention(thin) (Builtin.Int32) -> ()
  %9 = load %2 : $*(S4, Builtin.Int16)
  %10 = tuple_element_addr %2 : $*(S4, Builtin.Int16), 1
  store %1 to %10 : $*Builtin.Int16
  dealloc_stack %2 : $*(S4, Builtin.Int16)
  %11 = tuple()
  return %11 : $()
}

/////////////////////////////////
// Tuple with Tuple Field Test //
/////////////////////////////////

sil @use_tup2 : $@convention(thin) ((Builtin.Int64, Builtin.Int32)) -> ()
sil @use_int16 : $@convention(thin) (Builtin.Int16) -> ()

// CHECK-LABEL: sil @tuple_with_tuple_fields : $@convention(thin) (((Builtin.Int64, Builtin.Int32), Builtin.Int16), Builtin.Int16) -> ()
// CHECK: bb0([[VAR_0:%[0-9]+]] : $((Builtin.Int64, Builtin.Int32), Builtin.Int16), [[VAR_1:%[0-9]+]] : $Builtin.Int16):
// CHECK:   [[VAR_2:%[0-9]+]] = alloc_stack $Builtin.Int64
// CHECK:   [[VAR_3:%[0-9]+]] = alloc_stack $Builtin.Int32
// CHECK:   [[VAR_4:%[0-9]+]] = alloc_stack $Builtin.Int16
// CHECK:   [[VAR_5:%[0-9]+]] = tuple_extract [[VAR_0]] : $((Builtin.Int64, Builtin.Int32), Builtin.Int16), 0
// CHECK:   [[VAR_10:%[0-9]+]] = tuple_extract [[VAR_0]] : $((Builtin.Int64, Builtin.Int32), Builtin.Int16), 1
// CHECK:   [[VAR_6:%[0-9]+]] = tuple_extract [[VAR_5]] : $(Builtin.Int64, Builtin.Int32), 0
// CHECK:   [[VAR_8:%[0-9]+]] = tuple_extract [[VAR_5]] : $(Builtin.Int64, Builtin.Int32), 1
// CHECK:   store [[VAR_6]] to [[VAR_2]] : $*Builtin.Int64
// CHECK:   store [[VAR_8]] to [[VAR_3]] : $*Builtin.Int32
// CHECK:   store [[VAR_10]] to [[VAR_4]] : $*Builtin.Int16
// CHECK:   [[VAR_12:%[0-9]+]] = load [[VAR_2]] : $*Builtin.Int64
// CHECK:   [[VAR_13:%[0-9]+]] = load [[VAR_3]] : $*Builtin.Int32
// CHECK:   [[VAR_14:%[0-9]+]] = tuple ([[VAR_12]] : $Builtin.Int64, [[VAR_13]] : $Builtin.Int32)
// CHECK:   [[VAR_15:%[0-9]+]] = function_ref @use_tup2 : $@convention(thin) ((Builtin.Int64, Builtin.Int32)) -> ()
// CHECK:   [[VAR_16:%[0-9]+]] = apply [[VAR_15]]([[VAR_14]]) : $@convention(thin) ((Builtin.Int64, Builtin.Int32)) -> ()
// CHECK:   [[VAR_17:%[0-9]+]] = function_ref @use_int32 : $@convention(thin) (Builtin.Int32) -> ()
// CHECK:   [[VAR_18:%[0-9]+]] = load [[VAR_3]] : $*Builtin.Int32
// CHECK:   [[VAR_19:%[0-9]+]] = apply [[VAR_17]]([[VAR_18]]) : $@convention(thin) (Builtin.Int32) -> ()
// CHECK:   [[VAR_20:%[0-9]+]] = load [[VAR_2]] : $*Builtin.Int64
// CHECK:   [[VAR_21:%[0-9]+]] = load [[VAR_3]] : $*Builtin.Int32
// CHECK:   [[VAR_22:%[0-9]+]] = tuple ([[VAR_20]] : $Builtin.Int64, [[VAR_21]] : $Builtin.Int32)
// CHECK:   [[VAR_23:%[0-9]+]] = load [[VAR_4]] : $*Builtin.Int16
// CHECK:   [[VAR_24:%[0-9]+]] = tuple ([[VAR_22]] : $(Builtin.Int64, Builtin.Int32), [[VAR_23]] : $Builtin.Int16)
// CHECK:   store [[VAR_1]] to [[VAR_4]] : $*Builtin.Int16
// CHECK:   dealloc_stack [[VAR_4]] : $*Builtin.Int16
// CHECK:   dealloc_stack [[VAR_3]] : $*Builtin.Int32
// CHECK:   dealloc_stack [[VAR_2]] : $*Builtin.Int64
// CHECK:   [[VAR_29:%[0-9]+]] = tuple ()
// CHECK:   return [[VAR_29]] : $()
sil @tuple_with_tuple_fields : $@convention(thin) (((Builtin.Int64, Builtin.Int32), Builtin.Int16), Builtin.Int16) -> () {
bb0(%0 : $((Builtin.Int64, Builtin.Int32), Builtin.Int16), %1 : $Builtin.Int16):
  %2 = alloc_stack $((Builtin.Int64, Builtin.Int32), Builtin.Int16)
  store %0 to %2 : $*((Builtin.Int64, Builtin.Int32), Builtin.Int16)
  %3 = tuple_element_addr %2 : $*((Builtin.Int64, Builtin.Int32), Builtin.Int16), 0
  %4 = load %3 : $*(Builtin.Int64, Builtin.Int32)
  %5 = function_ref @use_tup2 : $@convention(thin) ((Builtin.Int64, Builtin.Int32)) -> ()
  apply %5(%4) : $@convention(thin) ((Builtin.Int64, Builtin.Int32)) -> ()
  %6 = tuple_element_addr %3 : $*(Builtin.Int64, Builtin.Int32), 1
  %7 = function_ref @use_int32 : $@convention(thin) (Builtin.Int32) -> ()
  %8 = load %6 : $*Builtin.Int32
  apply %7(%8) : $@convention(thin) (Builtin.Int32) -> ()
  %9 = load %2 : $*((Builtin.Int64, Builtin.Int32), Builtin.Int16)
  %10 = tuple_element_addr %2 : $*((Builtin.Int64, Builtin.Int32), Builtin.Int16), 1
  store %1 to %10 : $*Builtin.Int16
  dealloc_stack %2 : $*((Builtin.Int64, Builtin.Int32), Builtin.Int16)
  %11 = tuple()
  return %11 : $()
}

/////////////////////////
// Capture Struct Test //
/////////////////////////

struct CapturedS {
  var x : Builtin.Int32
}

sil @use_capturedstruct : $@convention(thin) (@inout CapturedS) -> ()

// CHECK-LABEL: sil @captured_struct : $@convention(thin) (CapturedS) -> ()
// CHECK: bb0([[VAR_0:%[0-9]+]] : $CapturedS):
// CHECK:   [[VAR_1:%[0-9]+]] = alloc_stack $CapturedS
// CHECK:   store [[VAR_0]] to [[VAR_1]] : $*CapturedS
// CHECK:   [[VAR_3:%[0-9]+]] = struct_element_addr [[VAR_1]] : $*CapturedS, #CapturedS.x
// CHECK:   [[VAR_4:%[0-9]+]] = load [[VAR_3]] : $*Builtin.Int32
// CHECK:   [[VAR_5:%[0-9]+]] = function_ref @use_capturedstruct : $@convention(thin) (@inout CapturedS) -> ()
// CHECK:   [[VAR_6:%[0-9]+]] = apply [[VAR_5]]([[VAR_1]]) : $@convention(thin) (@inout CapturedS) -> ()
// CHECK:   [[VAR_7:%[0-9]+]] = load [[VAR_3]] : $*Builtin.Int32
// CHECK:   dealloc_stack [[VAR_1]] : $*CapturedS
// CHECK:   [[VAR_9:%[0-9]+]] = tuple ()
// CHECK:   return [[VAR_9]] : $()
sil @captured_struct : $@convention(thin) (CapturedS) -> () {
bb0(%0 : $CapturedS):
  %1 = alloc_stack $CapturedS
  store %0 to %1 : $*CapturedS
  %3 = struct_element_addr %1 : $*CapturedS, #CapturedS.x
  %4 = load %3 : $*Builtin.Int32
  %5 = function_ref @use_capturedstruct : $@convention(thin) (@inout CapturedS) -> ()
  %6 = apply %5(%1) : $@convention(thin) (@inout CapturedS) -> ()
  %7 = load %3 : $*Builtin.Int32
  dealloc_stack %1 : $*CapturedS
  %9 = tuple ()
  return %9 : $()
}

/////////////////////////
// Captured Tuple Test //
/////////////////////////

sil @use_capturedtuple : $@convention(thin) (@inout (Builtin.Int32, Builtin.Int64)) -> ()

// CHECK-LABEL: sil @captured_tuple : $@convention(thin) ((Builtin.Int32, Builtin.Int64)) -> ()
// CHECK: bb0([[VAR_0:%[0-9]+]] : $(Builtin.Int32, Builtin.Int64)):
// CHECK:   [[VAR_1:%[0-9]+]] = alloc_stack $(Builtin.Int32, Builtin.Int64)
// CHECK:   store [[VAR_0]] to [[VAR_1]] : $*(Builtin.Int32, Builtin.Int64)
// CHECK:   [[VAR_3:%[0-9]+]] = tuple_element_addr [[VAR_1]] : $*(Builtin.Int32, Builtin.Int64), 0
// CHECK:   [[VAR_4:%[0-9]+]] = load [[VAR_3]] : $*Builtin.Int32
// CHECK:   [[VAR_5:%[0-9]+]] = function_ref @use_capturedtuple : $@convention(thin) (@inout (Builtin.Int32, Builtin.Int64)) -> ()
// CHECK:   [[VAR_6:%[0-9]+]] = apply [[VAR_5]]([[VAR_1]]) : $@convention(thin) (@inout (Builtin.Int32, Builtin.Int64)) -> ()
// CHECK:   [[VAR_7:%[0-9]+]] = load [[VAR_3]] : $*Builtin.Int32
// CHECK:   dealloc_stack [[VAR_1]] : $*(Builtin.Int32, Builtin.Int64)
// CHECK:   [[VAR_9:%[0-9]+]] = tuple ()
// CHECK:   return [[VAR_9]] : $()
sil @captured_tuple : $@convention(thin) ((Builtin.Int32, Builtin.Int64)) -> () {
bb0(%0 : $(Builtin.Int32, Builtin.Int64)):
  %1 = alloc_stack $(Builtin.Int32, Builtin.Int64)
  store %0 to %1 : $*(Builtin.Int32, Builtin.Int64)
  %3 = tuple_element_addr %1 : $*(Builtin.Int32, Builtin.Int64), 0
  %4 = load %3 : $*Builtin.Int32
  %5 = function_ref @use_capturedtuple : $@convention(thin) (@inout (Builtin.Int32, Builtin.Int64)) -> ()
  %6 = apply %5(%1) : $@convention(thin) (@inout (Builtin.Int32, Builtin.Int64)) -> ()
  %7 = load %3 : $*Builtin.Int32
  dealloc_stack %1 : $*(Builtin.Int32, Builtin.Int64)
  %9 = tuple ()
  return %9 : $()
}