5
5
// Test that makes sure that throughout the pipeline we properly handle
6
6
// conditional releases for trivial and non-trivial move only types.
7
7
8
- //////////////////////
9
- // Misc Declaration //
10
- //////////////////////
8
+ ////////////////////////////
9
+ // MARK: Misc Declaration //
10
+ ////////////////////////////
11
11
12
12
class Klass { }
13
13
14
- /////////////////////////
15
- // Struct Declarations //
16
- /////////////////////////
14
+ ///////////////////////////////
15
+ // MARK: Struct Declarations //
16
+ ///////////////////////////////
17
+
18
+ @inline ( never)
19
+ func doSomething( ) {
20
+ print ( " 123 " )
21
+ }
17
22
18
23
@_moveOnly
19
24
struct KlassPairWithoutDeinit {
@@ -27,7 +32,7 @@ struct KlassPairWithDeinit {
27
32
var rhs = Klass ( )
28
33
29
34
deinit {
30
- print ( " 123 " )
35
+ doSomething ( )
31
36
}
32
37
}
33
38
@@ -43,7 +48,7 @@ struct IntPairWithDeinit {
43
48
var k2 : Int = 6
44
49
45
50
deinit {
46
- print ( " 123 " )
51
+ doSomething ( )
47
52
}
48
53
}
49
54
@@ -54,9 +59,27 @@ func consumeKlassPairWithDeinit(_ x: __owned KlassPairWithDeinit) { }
54
59
55
60
var value : Bool { false }
56
61
57
- //////////////////
58
- // Struct Tests //
59
- //////////////////
62
+ //////////////////////////////////////
63
+ // MARK: Struct Deinit Output Tests //
64
+ //////////////////////////////////////
65
+
66
+ // SILGEN-LABEL: sil hidden [ossa] @$s16moveonly_deinits19KlassPairWithDeinitVfD : $@convention(method) (@owned KlassPairWithDeinit) -> () {
67
+ // SILGEN: bb0([[ARG:%.*]] :
68
+ // SILGEN: [[MARK:%.*]] = mark_must_check [consumable_and_assignable] [[ARG]]
69
+ // SILGEN: ([[LHS:%.*]], [[RHS:%.*]]) = destructure_struct [[MARK]]
70
+ // SILGEN: destroy_value [[LHS]]
71
+ // SILGEN: destroy_value [[RHS]]
72
+ // SILGEN: } // end sil function '$s16moveonly_deinits19KlassPairWithDeinitVfD'
73
+
74
+ // SILGEN-LABEL: sil hidden [ossa] @$s16moveonly_deinits17IntPairWithDeinitVfD : $@convention(method) (@owned IntPairWithDeinit) -> () {
75
+ // SILGEN: bb0([[ARG:%.*]] :
76
+ // SILGEN: [[MARKED:%.*]] = mark_must_check [consumable_and_assignable] [[ARG]]
77
+ // SILGEN: end_lifetime [[MARKED]]
78
+ // SILGEN: } // end sil function '$s16moveonly_deinits17IntPairWithDeinitVfD'
79
+
80
+ ////////////////////////
81
+ // MARK: Struct Tests //
82
+ ////////////////////////
60
83
61
84
// SILGEN-LABEL: sil [ossa] @$s16moveonly_deinits24testIntPairWithoutDeinityyF : $@convention(thin) () -> () {
62
85
// SILGEN: [[BOX:%.*]] = alloc_box
@@ -259,9 +282,9 @@ public func testKlassPairWithDeinit() {
259
282
}
260
283
}
261
284
262
- ///////////////////////
263
- // Enum Declarations //
264
- ///////////////////////
285
+ /////////////////////////////
286
+ // MARK: Enum Declarations //
287
+ /////////////////////////////
265
288
266
289
@_moveOnly
267
290
enum KlassEnumPairWithoutDeinit {
@@ -275,7 +298,7 @@ enum KlassEnumPairWithDeinit {
275
298
case rhs( Klass )
276
299
277
300
deinit {
278
- print ( " 123 " )
301
+ doSomething ( )
279
302
}
280
303
}
281
304
@@ -291,7 +314,7 @@ enum IntEnumPairWithDeinit {
291
314
case rhs( Int )
292
315
293
316
deinit {
294
- print ( " 123 " )
317
+ doSomething ( )
295
318
}
296
319
}
297
320
@@ -300,9 +323,47 @@ func consumeIntEnumPairWithDeinit(_ x: __owned IntEnumPairWithDeinit) { }
300
323
func consumeKlassEnumPairWithoutDeinit( _ x: __owned KlassEnumPairWithoutDeinit) { }
301
324
func consumeKlassEnumPairWithDeinit( _ x: __owned KlassEnumPairWithDeinit) { }
302
325
303
- ////////////////
304
- // Enum Tests //
305
- ////////////////
326
+ ////////////////////////////////////
327
+ // MARK: Enum Deinit Output Tests //
328
+ ////////////////////////////////////
329
+
330
+ // SILGEN-LABEL: sil hidden [ossa] @$s16moveonly_deinits23KlassEnumPairWithDeinitOfD : $@convention(method) (@owned KlassEnumPairWithDeinit) -> () {
331
+ // SILGEN: bb0([[ARG:%.*]] :
332
+ // SILGEN: [[MARK:%.*]] = mark_must_check [consumable_and_assignable] [[ARG]]
333
+ // SILGEN: switch_enum [[MARK]] : $KlassEnumPairWithDeinit, case #KlassEnumPairWithDeinit.lhs!enumelt: [[BB_LHS:bb[0-9]+]], case #KlassEnumPairWithDeinit.rhs!enumelt: [[BB_RHS:bb[0-9]+]]
334
+ //
335
+ // SILGEN: [[BB_LHS]]([[ARG:%.*]] :
336
+ // SILGEN-NEXT: destroy_value [[ARG]]
337
+ // SILGEN-NEXT: br [[BB_CONT:bb[0-9]+]]
338
+ //
339
+ // SILGEN: [[BB_RHS]]([[ARG:%.*]] :
340
+ // SILGEN-NEXT: destroy_value [[ARG]]
341
+ // SILGEN-NEXT: br [[BB_CONT]]
342
+ //
343
+ // SILGEN: [[BB_CONT]]:
344
+ // SILGEN-NEXT: tuple ()
345
+ // SILGEN-NEXT: return
346
+ // SILGEN: } // end sil function '$s16moveonly_deinits23KlassEnumPairWithDeinitOfD'
347
+
348
+ // SILGEN-LABEL: sil hidden [ossa] @$s16moveonly_deinits21IntEnumPairWithDeinitOfD : $@convention(method) (@owned IntEnumPairWithDeinit) -> () {
349
+ // SILGEN: bb0([[ARG:%.*]] :
350
+ // SILGEN: [[MARK:%.*]] = mark_must_check [consumable_and_assignable] [[ARG]]
351
+ // SILGEN: switch_enum [[MARK]] : $IntEnumPairWithDeinit, case #IntEnumPairWithDeinit.lhs!enumelt: [[BB_LHS:bb[0-9]+]], case #IntEnumPairWithDeinit.rhs!enumelt: [[BB_RHS:bb[0-9]+]]
352
+ //
353
+ // SILGEN: [[BB_LHS]]([[ARG:%.*]] :
354
+ // SILGEN-NEXT: br [[BB_CONT:bb[0-9]+]]
355
+ //
356
+ // SILGEN: [[BB_RHS]]([[ARG:%.*]] :
357
+ // SILGEN-NEXT: br [[BB_CONT]]
358
+ //
359
+ // SILGEN: [[BB_CONT]]:
360
+ // SILGEN-NEXT: tuple ()
361
+ // SILGEN-NEXT: return
362
+ // SILGEN: } // end sil function '$s16moveonly_deinits21IntEnumPairWithDeinitOfD'
363
+
364
+ //////////////////////
365
+ // MARK: Enum Tests //
366
+ //////////////////////
306
367
307
368
// SILGEN-LABEL: sil [ossa] @$s16moveonly_deinits28testIntEnumPairWithoutDeinityyF : $@convention(thin) () -> () {
308
369
// SILGEN: [[BOX:%.*]] = alloc_box
0 commit comments