File: definite_init.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 (589 lines) | stat: -rw-r--r-- 22,232 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
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
// RUN: %target-sil-opt -module-name Swift -enable-sil-verify-all=0 -o /dev/null %s 2>&1
// REQUIRES: asserts

sil_stage raw

import Builtin

enum Never { }
protocol Error { }

enum Optional<T> {
case some(T)
case none
}

struct Bool {
  var value: Builtin.Int1
}

// This file is meant to contain tests that previously the verifier treated
// incorrectly. This is important to ensure that the verifier does not
// regress. It should only deal with use matching in a DI context.
//
// *NOTE* This was originally a test file for definite_init.sil that looked
// interesting from an ownership perspective. So I took it and reused it to get
// coverage here.

sil @takes_Int_inout : $@convention(thin) (@inout Builtin.Int32) -> ()
sil @makesInt : $@convention(thin) () -> Builtin.Int32

// func used_by_inout(a : Builtin.Int32) -> (Builtin.Int32, Builtin.Int32) {
//  var t = a
//  takes_Int_inout(&a)
//  return (t, a)
//}
sil [ossa] @used_by_inout : $@convention(thin) (Builtin.Int32) -> (Builtin.Int32, Builtin.Int32) {
bb0(%0 : $Builtin.Int32):
  %2 = alloc_box $<τ_0_0> { var τ_0_0 } <Builtin.Int32>
  %3 = mark_uninitialized [var] %2 : $<τ_0_0> { var τ_0_0 } <Builtin.Int32>
  %4 = project_box %3 : $<τ_0_0> { var τ_0_0 } <Builtin.Int32>, 0
  store %0 to [trivial] %4 : $*Builtin.Int32
  %5 = load [trivial] %4 : $*Builtin.Int32
  %6 = function_ref @takes_Int_inout : $@convention(thin) (@inout Builtin.Int32) -> ()
  %7 = apply %6(%4) : $@convention(thin) (@inout Builtin.Int32) -> ()
  %8 = load [trivial] %4 : $*Builtin.Int32
  %9 = tuple (%5 : $Builtin.Int32, %8 : $Builtin.Int32)
  destroy_value %3 : $<τ_0_0> { var τ_0_0 } <Builtin.Int32>
  return %9 : $(Builtin.Int32, Builtin.Int32)
}

struct AddressOnlyStruct {
  var a : Any
  var b : Builtin.Int32
}

/// returns_generic_struct - This returns a struct by reference.
sil @returns_generic_struct : $@convention(thin) () -> @out AddressOnlyStruct

// There should be no error in this function.
sil [ossa] @call_struct_return_function : $@convention(thin) () -> Builtin.Int32 {
bb0:
  %0 = alloc_box $<τ_0_0> { var τ_0_0 } <AddressOnlyStruct>
  %0a = mark_uninitialized [var] %0 : $<τ_0_0> { var τ_0_0 } <AddressOnlyStruct>
  %1 = project_box %0a : $<τ_0_0> { var τ_0_0 } <AddressOnlyStruct>, 0
  %2 = function_ref @returns_generic_struct : $@convention(thin) () -> @out AddressOnlyStruct
  %3 = apply %2(%1) : $@convention(thin) () -> @out AddressOnlyStruct
  %4 = struct_element_addr %1 : $*AddressOnlyStruct, #AddressOnlyStruct.b
  %5 = load [trivial] %4 : $*Builtin.Int32
  destroy_value %0a : $<τ_0_0> { var τ_0_0 } <AddressOnlyStruct>
  return %5 : $Builtin.Int32
}

sil [ossa] @copy_addr1 : $@convention(thin) <T> (@in T) -> @out T {
bb0(%0 : $*T, %1 : $*T):
  %3 = alloc_box $<τ_0_0> { var τ_0_0 } <T>
  %3a = mark_uninitialized [var] %3 : $<τ_0_0> { var τ_0_0 } <T>
  %4 = project_box %3a : $<τ_0_0> { var τ_0_0 } <T>, 0
  copy_addr [take] %1 to [init] %4 : $*T
  copy_addr %4 to [init] %0 : $*T
  destroy_value %3a : $<τ_0_0> { var τ_0_0 } <T>
  %9 = tuple ()
  return %9 : $()
}

class SomeClass {}

sil @getSomeClass : $@convention(thin) () -> @owned SomeClass
sil @getSomeOptionalClass : $@convention(thin) () -> Optional<SomeClass>

sil [ossa] @assign_test_trivial : $@convention(thin) (Builtin.Int32) -> Builtin.Int32 {
bb0(%0 : $Builtin.Int32):
  %7 = alloc_box $<τ_0_0> { var τ_0_0 } <Builtin.Int32>
  %7a = mark_uninitialized [var] %7 : $<τ_0_0> { var τ_0_0 } <Builtin.Int32>
  %1 = project_box %7a : $<τ_0_0> { var τ_0_0 } <Builtin.Int32>, 0

  // These assigns are a mix of init + store forms, but because Int is trivial,
  // they all turn into stores.
  assign %0 to %1 : $*Builtin.Int32
  assign %0 to %1 : $*Builtin.Int32
  assign %0 to %1 : $*Builtin.Int32

  %2 = load [trivial] %1 : $*Builtin.Int32
  destroy_value %7a : $<τ_0_0> { var τ_0_0 } <Builtin.Int32>

  return %2 : $Builtin.Int32
}

sil [ossa] @assign_test_nontrivial : $@convention(thin) () -> () {
bb0:
  // Assignments of nontrivial types.  The first becomes an initialize (i.e.,
  // lone store), the second becomes an assignment (retain/release dance).

  %b = alloc_box $<τ_0_0> { var τ_0_0 } <SomeClass>
  %ba = mark_uninitialized [var] %b : $<τ_0_0> { var τ_0_0 } <SomeClass>
  %c = project_box %ba : $<τ_0_0> { var τ_0_0 } <SomeClass>, 0
  %f = function_ref @getSomeClass : $@convention(thin) () -> @owned SomeClass
  %4 = apply %f() : $@convention(thin) () -> @owned SomeClass
  assign %4 to %c : $*SomeClass
  %8 = apply %f() : $@convention(thin) () -> @owned SomeClass
  assign %8 to %c : $*SomeClass
  destroy_addr %c : $*SomeClass
  dealloc_box %ba : $<τ_0_0> { var τ_0_0 } <SomeClass>
  %11 = tuple ()
  return %11 : $()
}

sil [ossa] @assign_test_addressonly : $@convention(thin) <T> (@in T) -> @out T {
bb0(%0 : $*T, %1 : $*T):
  %b = alloc_box $<τ_0_0> { var τ_0_0 } <T>
  %ba = mark_uninitialized [var] %b : $<τ_0_0> { var τ_0_0 } <T>
  %2 = project_box %ba : $<τ_0_0> { var τ_0_0 } <T>, 0
  copy_addr %1 to %2 : $*T
  copy_addr [take] %1 to %2 : $*T
  copy_addr %2 to [init] %0 : $*T
  destroy_value %ba : $<τ_0_0> { var τ_0_0 } <T>
  %9 = tuple ()
  return %9 : $()
}

sil [ossa] @assign_test_unowned : $@convention(thin) () -> () {
bb0:
  %b = alloc_box $<τ_0_0> { var τ_0_0 } <@sil_unowned SomeClass>
  %ba = mark_uninitialized [var] %b : $<τ_0_0> { var τ_0_0 } <@sil_unowned SomeClass>
  %c = project_box %ba : $<τ_0_0> { var τ_0_0 } <@sil_unowned SomeClass>, 0

  %f = function_ref @getSomeClass : $@convention(thin) () -> @owned SomeClass

  %4 = apply %f() : $@convention(thin) () -> @owned SomeClass
  %5 = ref_to_unowned %4 : $SomeClass to $@sil_unowned SomeClass
  %6 = copy_value %5 : $@sil_unowned SomeClass
  assign %6 to %c : $*@sil_unowned SomeClass
  destroy_value %4 : $SomeClass
  %8 = apply %f() : $@convention(thin) () -> @owned SomeClass
  %9 = ref_to_unowned %8 : $SomeClass to $@sil_unowned SomeClass
  %10 = copy_value %9 : $@sil_unowned SomeClass
  assign %10 to %c : $*@sil_unowned SomeClass

  destroy_value %8 : $SomeClass
  destroy_addr %c : $*@sil_unowned SomeClass
  dealloc_box %ba : $<τ_0_0> { var τ_0_0 } <@sil_unowned SomeClass>

  %11 = tuple ()
  return %11 : $()
}

struct ContainsNativeObject {
  var x : Builtin.Int32
  var y : Builtin.NativeObject
}

sil [ossa] @test_struct : $@convention(thin) (@inout ContainsNativeObject) -> () {
bb0(%0 : $*ContainsNativeObject):
  %b = alloc_box $<τ_0_0> { var τ_0_0 } <ContainsNativeObject>
  %ba = mark_uninitialized [var] %b : $<τ_0_0> { var τ_0_0 } <ContainsNativeObject>
  %c = project_box %ba : $<τ_0_0> { var τ_0_0 } <ContainsNativeObject>, 0
  %1 = load [copy] %0 : $*ContainsNativeObject
  assign %1 to %c : $*ContainsNativeObject

  destroy_value %ba : $<τ_0_0> { var τ_0_0 } <ContainsNativeObject>
  %x = tuple ()
  return %x : $()
}

sil [ossa] @non_box_assign_trivial : $@convention(thin) (@inout Bool, Bool) -> () {
bb0(%0 : $*Bool, %1 : $Bool):
  assign %1 to %0 : $*Bool
  %9 = tuple ()
  return %9 : $()
}
sil [ossa] @non_box_assign : $@convention(thin) (@inout SomeClass, @owned SomeClass) -> () {
bb0(%0 : $*SomeClass, %1 : @owned $SomeClass):
  assign %1 to %0 : $*SomeClass
  %9 = tuple ()
  return %9 : $()
}

sil_global @int_global : $Builtin.Int32

// CHECK-LABEL: sil [ossa] @test_tlc
// CHECK-NOT: mark_uninitialized
// CHECK: return
sil [ossa] @test_tlc : $() -> () {
  %0 = global_addr @int_global : $*Builtin.Int32
  %1 = mark_uninitialized [var] %0 : $*Builtin.Int32

  %9 = tuple ()
  return %9 : $()
}


struct XYStruct { var x, y : Builtin.Int32 }
sil @init_xy_struct : $@convention(thin) () -> XYStruct



protocol P {}
class C : P {}

sil @use : $@convention(thin) (@in P) -> ()


sil [ossa] @release_not_constructed : $@convention(thin) () -> () {
bb0:
  %3 = alloc_stack $SomeClass
  %c = mark_uninitialized [var] %3 : $*SomeClass
  destroy_addr %c : $*SomeClass
  dealloc_stack %3 : $*SomeClass
  %15 = tuple ()
  return %15 : $()
}

sil [ossa] @release_some_constructed : $@convention(thin) () -> () {
bb0:
  %0 = tuple ()
  %b = alloc_stack $(SomeClass, SomeClass)
  %1 = mark_uninitialized [var] %b : $*(SomeClass, SomeClass)
  %2 = function_ref @getSomeClass : $@convention(thin) () -> @owned SomeClass
  %3 = apply %2() : $@convention(thin) () -> @owned SomeClass
  %4 = tuple_element_addr %1 : $*(SomeClass, SomeClass), 0
  store %3 to [init] %4 : $*SomeClass
  destroy_addr %1 : $*(SomeClass, SomeClass)
  dealloc_stack %b : $*(SomeClass, SomeClass)
  %8 = tuple ()
  return %8 : $()
}

sil [ossa] @init_existential_with_class : $@convention(thin) (@inout C) -> () {
entry(%a : $*C):
  %p = alloc_stack $P
  %b = mark_uninitialized [var] %p : $*P
  %q = init_existential_addr %b : $*P, $C
  copy_addr %a to [init] %q : $*C
  %u = function_ref @use : $@convention(thin) (@in P) -> ()
  %v = apply %u(%b) : $@convention(thin) (@in P) -> ()
  dealloc_stack %p : $*P
  %z = tuple ()
  return %z : $()
}

sil [ossa] @conditional_init : $@convention(thin) (Bool) -> () {
bb0(%0 : $Bool):
  %2 = alloc_stack $SomeClass
  %3 = mark_uninitialized [var] %2 : $*SomeClass
  %5 = integer_literal $Builtin.Int1, 1
  cond_br %5, bb1, bb2

bb1:
  %f = function_ref @getSomeClass : $@convention(thin) () -> @owned SomeClass
  %6 = apply %f() : $@convention(thin) () -> @owned SomeClass
  assign %6 to %3 : $*SomeClass
  br bb3

bb2:
  br bb3

bb3:
  destroy_addr %3 : $*SomeClass
  dealloc_stack %2 : $*SomeClass
  %14 = tuple ()
  return %14 : $()
}

sil [ossa] @conditionalInitOrAssign : $@convention(thin) (Builtin.Int1) -> () {
bb0(%0 : $Builtin.Int1):
  %5 = alloc_stack $SomeClass
  %6 = mark_uninitialized [var] %5 : $*SomeClass
  cond_br %0, bb1, bb2

bb1:
  %2 = function_ref @getSomeClass : $@convention(thin) () -> @owned SomeClass
  %12 = apply %2() : $@convention(thin) () -> @owned SomeClass
  assign %12 to %6 : $*SomeClass                // id: %13
  br bb3                                          // id: %14

bb2:
  br bb3

bb3:
  %3 = function_ref @getSomeClass : $@convention(thin) () -> @owned SomeClass
  %17 = apply %3() : $@convention(thin) () -> @owned SomeClass
  assign %17 to %6 : $*SomeClass                // id: %18
  destroy_addr %6 : $*SomeClass                 // id: %19
  dealloc_stack %5 : $*SomeClass // id: %20
  %23 = tuple ()                                  // user: %24
  return %23 : $()                                // id: %24
}

class RootClassWithIVars {
  var x: Builtin.Int32
  var y: Builtin.Int32
  var z: (Builtin.Int32, Builtin.Int32)
  init()
}

/// Root class tests.
sil [ossa] @rootclass_test1 : $@convention(method) (@owned RootClassWithIVars, Builtin.Int32) -> @owned RootClassWithIVars {
bb0(%0 : @owned $RootClassWithIVars, %1 : $Builtin.Int32):
  %3 = mark_uninitialized [rootself] %0 : $RootClassWithIVars
  %4 = begin_borrow %3 : $RootClassWithIVars
  %10 = ref_element_addr %4 : $RootClassWithIVars, #RootClassWithIVars.x
  assign %1 to %10 : $*Builtin.Int32

  %11 = ref_element_addr %4 : $RootClassWithIVars, #RootClassWithIVars.y
  assign %1 to %11 : $*Builtin.Int32

  %12 = ref_element_addr %4 : $RootClassWithIVars, #RootClassWithIVars.z
  %13 = tuple_element_addr %12 : $*(Builtin.Int32, Builtin.Int32), 0
  assign %1 to %13 : $*Builtin.Int32
  %14 = tuple_element_addr %12 : $*(Builtin.Int32, Builtin.Int32), 1
  assign %1 to %14 : $*Builtin.Int32
  end_borrow %4 : $RootClassWithIVars
  return %3 : $RootClassWithIVars
}

class DerivedClassWithIVars : RootClassWithIVars {
  var a: Builtin.Int32
  override init()
}

sil @superinit : $@convention(method) (@owned RootClassWithIVars) -> @owned RootClassWithIVars


sil [ossa] @derived_test1 : $@convention(method) (@owned DerivedClassWithIVars) -> @owned DerivedClassWithIVars {
bb0(%0 : @owned $DerivedClassWithIVars):
  %1 = alloc_box $<τ_0_0> { var τ_0_0 } <DerivedClassWithIVars>
  %1a = mark_uninitialized [derivedself] %1 : $<τ_0_0> { var τ_0_0 } <DerivedClassWithIVars>
  %3 = project_box %1a : $<τ_0_0> { var τ_0_0 } <DerivedClassWithIVars>, 0
  store %0 to [init] %3 : $*DerivedClassWithIVars

  // Get an int
  %5 = function_ref @makesInt : $@convention(thin) () -> Builtin.Int32
  %7 = apply %5() : $@convention(thin) () -> Builtin.Int32

  // Initialize the 'a' ivar with the int.
  %8 = load_borrow %3 : $*DerivedClassWithIVars
  %9 = ref_element_addr %8 : $DerivedClassWithIVars, #DerivedClassWithIVars.a
  assign %7 to %9 : $*Builtin.Int32
  end_borrow %8 : $DerivedClassWithIVars

  %11 = load [take] %3 : $*DerivedClassWithIVars
  %13 = upcast %11 : $DerivedClassWithIVars to $RootClassWithIVars
  %14 = function_ref @superinit : $@convention(method) (@owned RootClassWithIVars) -> @owned RootClassWithIVars
  %15 = apply %14(%13) : $@convention(method) (@owned RootClassWithIVars) -> @owned RootClassWithIVars
  %16 = unconditional_checked_cast %15 : $RootClassWithIVars to DerivedClassWithIVars
  assign %16 to %3 : $*DerivedClassWithIVars

  %18 = load [copy] %3 : $*DerivedClassWithIVars
  destroy_value %1a : $<τ_0_0> { var τ_0_0 } <DerivedClassWithIVars>
  return %18 : $DerivedClassWithIVars
}

struct MyStruct : P {}

sil [ossa] @self_init_assert_instruction : $@convention(thin) (Builtin.Int32, @thin MyStruct.Type) -> MyStruct {
bb0(%0 : $Builtin.Int32, %1 : $@thin MyStruct.Type):
  %2 = alloc_stack $MyStruct, var, name "sf"
  %3 = mark_uninitialized [delegatingself] %2 : $*MyStruct
  %6 = function_ref @selfinit : $@convention(thin) () -> MyStruct
  %7 = apply %6() : $@convention(thin) () -> MyStruct
  assign %7 to %3 : $*MyStruct
  %9 = load [trivial] %3 : $*MyStruct
  dealloc_stack %2 : $*MyStruct
  return %9 : $MyStruct
}

sil @selfinit : $@convention(thin) () -> MyStruct

struct MyStruct2 {
  var x: P
    init(delegate: ())
    init()
}

sil @selfinit_delegate : $@convention(thin) (@thin MyStruct2.Type) -> @out MyStruct2

sil [ossa] @self_init_copyaddr : $@convention(thin) (@thin MyStruct2.Type) -> @out MyStruct2 {
bb0(%0 : $*MyStruct2, %1 : $@thin MyStruct2.Type):
  %2 = alloc_stack $MyStruct2, var, name "sf"
  %3 = mark_uninitialized [delegatingself] %2 : $*MyStruct2
  %6 = metatype $@thin MyStruct2.Type
  %7 = function_ref @selfinit_delegate : $@convention(thin) (@thin MyStruct2.Type) -> @out MyStruct2
  %8 = alloc_stack $MyStruct2
  apply %7(%8, %6) : $@convention(thin) (@thin MyStruct2.Type) -> @out MyStruct2
  copy_addr [take] %8 to %3 : $*MyStruct2
  dealloc_stack %8 : $*MyStruct2
  copy_addr [take] %3 to [init] %0 : $*MyStruct2
  dealloc_stack %2 : $*MyStruct2
  %13 = tuple ()
  return %13 : $()
}

class RootClassWithNontrivialStoredProperties {
  var x, y: SomeClass
  init()
}

class DerivedClassWithNontrivialStoredProperties : RootClassWithNontrivialStoredProperties {
  var a, b: SomeClass
  override init()
}

sil [ossa] @test_root_release : $@convention(method) (@owned RootClassWithNontrivialStoredProperties) -> () {
bb0(%0 : @owned $RootClassWithNontrivialStoredProperties):
  %4 = mark_uninitialized [rootself] %0 : $RootClassWithNontrivialStoredProperties
  destroy_value %4 : $RootClassWithNontrivialStoredProperties
  %13 = tuple ()
  return %13 : $()
}

sil [ossa] @test_root_partial_release : $@convention(method) (@owned RootClassWithNontrivialStoredProperties) -> () {
bb0(%0 : @owned $RootClassWithNontrivialStoredProperties):
  %4 = mark_uninitialized [rootself] %0 : $RootClassWithNontrivialStoredProperties
  %1 = alloc_ref $SomeClass
  %5 = begin_borrow %4 : $RootClassWithNontrivialStoredProperties
  %2 = ref_element_addr %5 : $RootClassWithNontrivialStoredProperties, #RootClassWithNontrivialStoredProperties.x
  assign %1 to %2 : $*SomeClass
  end_borrow %5 : $RootClassWithNontrivialStoredProperties
  destroy_value %4 : $RootClassWithNontrivialStoredProperties
  %13 = tuple ()
  return %13 : $()
}

sil [ossa] @test_derived_release : $@convention(method) (@owned DerivedClassWithNontrivialStoredProperties) -> () {
bb0(%0 : @owned $DerivedClassWithNontrivialStoredProperties):
  %1 = alloc_stack $DerivedClassWithNontrivialStoredProperties
  %4 = mark_uninitialized [derivedself] %1 : $*DerivedClassWithNontrivialStoredProperties
  store %0 to [init] %4 : $*DerivedClassWithNontrivialStoredProperties
  destroy_addr %4 : $*DerivedClassWithNontrivialStoredProperties
  dealloc_stack %1 : $*DerivedClassWithNontrivialStoredProperties
  %13 = tuple ()
  return %13 : $()
}

sil [ossa] @test_derived_partial_release : $@convention(method) (@owned DerivedClassWithNontrivialStoredProperties) -> () {
bb0(%0 : @owned $DerivedClassWithNontrivialStoredProperties):
  %1 = alloc_stack $DerivedClassWithNontrivialStoredProperties
  %4 = mark_uninitialized [derivedself] %1 : $*DerivedClassWithNontrivialStoredProperties
  store %0 to [init] %4 : $*DerivedClassWithNontrivialStoredProperties

  %8 = alloc_ref $SomeClass

  %9 = load_borrow %4 : $*DerivedClassWithNontrivialStoredProperties
  %10 = ref_element_addr %9 : $DerivedClassWithNontrivialStoredProperties, #DerivedClassWithNontrivialStoredProperties.a
  assign %8 to %10 : $*SomeClass
  end_borrow %9 : $DerivedClassWithNontrivialStoredProperties

  destroy_addr %4 : $*DerivedClassWithNontrivialStoredProperties
  dealloc_stack %1 : $*DerivedClassWithNontrivialStoredProperties
  %13 = tuple ()
  return %13 : $()
}

sil [ossa] @test_delegating_box_release : $@convention(method) (@owned RootClassWithNontrivialStoredProperties) -> () {
bb0(%0 : @owned $RootClassWithNontrivialStoredProperties):
  %2 = alloc_box $<τ_0_0> { var τ_0_0 } <RootClassWithNontrivialStoredProperties>
  %2a = mark_uninitialized [delegatingself] %2 : $<τ_0_0> { var τ_0_0 } <RootClassWithNontrivialStoredProperties>
  %4 = project_box %2a : $<τ_0_0> { var τ_0_0 } <RootClassWithNontrivialStoredProperties>, 0
  store %0 to [init] %4 : $*RootClassWithNontrivialStoredProperties
  destroy_value %2a : $<τ_0_0> { var τ_0_0 } <RootClassWithNontrivialStoredProperties>
  %13 = tuple ()
  return %13 : $()
}

sil [ossa] @test_delegating_rvalue_release : $@convention(method) (@owned RootClassWithNontrivialStoredProperties) -> () {
bb0(%0 : @owned $RootClassWithNontrivialStoredProperties):
  %2 = alloc_box $<τ_0_0> { var τ_0_0 } <RootClassWithNontrivialStoredProperties>
  %2a = mark_uninitialized [delegatingself] %2 : $<τ_0_0> { var τ_0_0 } <RootClassWithNontrivialStoredProperties>
  %4 = project_box %2a : $<τ_0_0> { var τ_0_0 } <RootClassWithNontrivialStoredProperties>, 0
  store %0 to [init] %4 : $*RootClassWithNontrivialStoredProperties
  %6 = load [take] %4 : $*RootClassWithNontrivialStoredProperties
  destroy_value %6 : $RootClassWithNontrivialStoredProperties
  destroy_value %2a : $<τ_0_0> { var τ_0_0 } <RootClassWithNontrivialStoredProperties>
  %13 = tuple ()
  return %13 : $()
}

sil [ossa] @test_delegating_derived_release : $@convention(method) (@owned DerivedClassWithNontrivialStoredProperties) -> () {
bb0(%0 : @owned $DerivedClassWithNontrivialStoredProperties):
  %2 = alloc_stack $DerivedClassWithNontrivialStoredProperties
  %4 = mark_uninitialized [delegatingself] %2 : $*DerivedClassWithNontrivialStoredProperties
  store %0 to [init] %4 : $*DerivedClassWithNontrivialStoredProperties
  destroy_addr %4 : $*DerivedClassWithNontrivialStoredProperties
  dealloc_stack %2 : $*DerivedClassWithNontrivialStoredProperties
  %13 = tuple ()
  return %13 : $()
}

sil [ossa] @super_init_out_of_order :  $@convention(method) (@owned DerivedClassWithIVars, Builtin.Int32) -> @owned DerivedClassWithIVars {
bb0(%0 : @owned $DerivedClassWithIVars, %i : $Builtin.Int32):
  %1 = alloc_box $<τ_0_0> { var τ_0_0 } <DerivedClassWithIVars>
  %1a = mark_uninitialized [derivedself] %1 : $<τ_0_0> { var τ_0_0 } <DerivedClassWithIVars>
  %3 = project_box %1a : $<τ_0_0> { var τ_0_0 } <DerivedClassWithIVars>, 0
  store %0 to [init] %3 : $*DerivedClassWithIVars

  %8 = load_borrow %3 : $*DerivedClassWithIVars
  %9 = ref_element_addr %8 : $DerivedClassWithIVars, #DerivedClassWithIVars.a
  assign %i to %9 : $*Builtin.Int32
  end_borrow %8 : $DerivedClassWithIVars

  %a = load [take] %3 : $*DerivedClassWithIVars
  %b = upcast %a : $DerivedClassWithIVars to $RootClassWithIVars
  %borrowed_b = begin_borrow %b : $RootClassWithIVars
  %c = ref_element_addr %borrowed_b : $RootClassWithIVars, #RootClassWithIVars.x
  load [trivial] %c : $*Builtin.Int32
  end_borrow %borrowed_b : $RootClassWithIVars
  %14 = function_ref @superinit : $@convention(method) (@owned RootClassWithIVars) -> @owned RootClassWithIVars
  %15 = apply %14(%b) : $@convention(method) (@owned RootClassWithIVars) -> @owned RootClassWithIVars

  %16 = unconditional_checked_cast %15 : $RootClassWithIVars to DerivedClassWithIVars
  assign %16 to %3 : $*DerivedClassWithIVars
  %18 = load [copy] %3 : $*DerivedClassWithIVars
  destroy_value %1a : $<τ_0_0> { var τ_0_0 } <DerivedClassWithIVars>
  return %18 : $DerivedClassWithIVars
}


struct MyStruct3 {
  @_hasStorage var c: C
}
sil @selfinit_mystruct3 : $@convention(thin) () -> @owned MyStruct3

sil hidden [ossa] @test_conditional_destroy_delegating_init : $@convention(thin) (Builtin.Int1) -> () {
bb0(%0 : $Builtin.Int1):
  %2 = alloc_stack $MyStruct3
  %3 = mark_uninitialized [delegatingself] %2 : $*MyStruct3
  cond_br %0, bb1, bb2

bb1:
  %9 = function_ref @selfinit_mystruct3 : $@convention(thin) () -> @owned MyStruct3
  %10 = apply %9() : $@convention(thin) () -> @owned MyStruct3
  assign %10 to %3 : $*MyStruct3
  br bb3

bb2:
  br bb3

bb3:
  destroy_addr %3 : $*MyStruct3
  dealloc_stack %2 : $*MyStruct3
  %15 = tuple ()
  return %15 : $()
}

class MyClass3 {
}
sil @selfinit_myclass3 : $@convention(thin) (@owned MyClass3) -> @owned MyClass3

sil hidden [ossa] @test_conditional_destroy_class_delegating_init : $@convention(thin) (Builtin.Int1) -> () {
bb0(%0 : $Builtin.Int1):
  %2 = alloc_stack $MyClass3
  %3 = mark_uninitialized [delegatingself] %2 : $*MyClass3
  cond_br %0, bb1, bb2

bb1:
  %4 = load [take] %3 : $*MyClass3
  %5 = function_ref @selfinit_myclass3 : $@convention(thin) (@owned MyClass3) -> @owned MyClass3
  %6 = apply %5(%4) : $@convention(thin) (@owned MyClass3) -> @owned MyClass3
  store %6 to [init] %3 : $*MyClass3
  br bb3

bb2:
  br bb3

bb3:
  destroy_addr %3 : $*MyClass3
  dealloc_stack %2 : $*MyClass3
  %7 = tuple ()
  return %7 : $()
}