@@ -1228,6 +1228,18 @@ bb2(%9 : $Error):
1228
1228
throw %9 : $Error
1229
1229
}
1230
1230
1231
+ // CHECK-LABEL: sil [ossa] @fixeeLifetime : {{.*}} {
1232
+ // CHECK: {{bb[0-9]+}}([[ADDR:%[^,]+]] : $*T):
1233
+ // CHECK: fix_lifetime [[ADDR]]
1234
+ // CHECK-LABEL: } // end sil function 'fixeeLifetime'
1235
+ sil [ossa] @fixeeLifetime : $@convention(thin) <T> (@in T) -> () {
1236
+ bb0(%instance : @owned $T):
1237
+ fix_lifetime %instance : $T
1238
+ destroy_value %instance : $T
1239
+ %retval = tuple ()
1240
+ return %retval : $()
1241
+ }
1242
+
1231
1243
// CHECK-LABEL: sil [ossa] @lexical_borrow_struct_extract {{.*}} {
1232
1244
// CHECK: [[PAIR_ADDR:%[^,]+]] = alloc_stack [lexical]
1233
1245
// CHECK: [[X_ADDR:%[^,]+]] = struct_element_addr [[PAIR_ADDR]]
@@ -1273,6 +1285,61 @@ entry(%instance : @owned $Pair<T>):
1273
1285
return %retval : $()
1274
1286
}
1275
1287
1288
+ /// Verify that alloc_stacks for which there is already a dealloc stack can be
1289
+ /// deleted.
1290
+ // CHECK-LABEL: sil [ossa] @partition : {{.*}} {
1291
+ // CHECK: {{bb[0-9]+}}([[INDEX_OUT:%[^,]+]] : $*Self.Index, [[SELF:%[^,]+]] : $*Self):
1292
+ // CHECK: [[MAYBE_INDEX_ADDR:%[^,]+]] = alloc_stack $Optional<Builtin.Int64>
1293
+ // CHECK: try_apply {{%[^,]+}}<Self, Builtin.Int64>([[MAYBE_INDEX_ADDR]], [[SELF]]) : $@convention(thin) <τ_0_0 where τ_0_0 : MyCollection><τ_1_0> (@inout τ_0_0) -> (@out Optional<τ_1_0>, @error any Error), normal [[YES_BLOCK:bb[0-9]+]], error [[NO_BLOCK:bb[0-9]+]]
1294
+ // CHECK: [[NO_BLOCK]]([[REGISTER_16:%[^,]+]] : @owned $any Error):
1295
+ // CHECK: dealloc_stack [[MAYBE_INDEX_ADDR]]
1296
+ // CHECK: br [[EXIT_ERROR:bb[0-9]+]]([[REGISTER_16]] : $any Error)
1297
+ // CHECK: [[EXIT_ERROR]]([[ERROR_TO_THROW:%[^,]+]] : @owned $any Error):
1298
+ // CHECK: throw [[ERROR_TO_THROW]]
1299
+ // CHECK: [[YES_BLOCK]]
1300
+ // CHECK: [[MAYBE_INDEX:%[^,]+]] = load [trivial] [[MAYBE_INDEX_ADDR]]
1301
+ // CHECK: dealloc_stack [[MAYBE_INDEX_ADDR]]
1302
+ // CHECK: switch_enum [[MAYBE_INDEX]] : $Optional<Builtin.Int64>, case #Optional.some!enumelt: [[SOME_BLOCK:bb[0-9]+]], case #Optional.none!enumelt: [[NONE_BLOCK:bb[0-9]+]]
1303
+ // CHECK: [[NONE_BLOCK]]:
1304
+ // CHECK: apply {{%[^,]+}}<Self>([[INDEX_OUT]], [[SELF]])
1305
+ // CHECK: [[SOME_BLOCK]]([[SOME_INDEX:%[^,]+]] : $Builtin.Int64):
1306
+ // CHECK: apply {{%[^,]+}}<Self>([[INDEX_OUT]], [[SOME_INDEX]])
1307
+ // CHECK-LABEL: } // end sil function 'partition'
1308
+ protocol MyCollection {
1309
+ associatedtype Index
1310
+ }
1311
+ sil [ossa] @impl : $@convention(method) <τ_0_0 where τ_0_0 : MyCollection> (@inout τ_0_0) -> @out τ_0_0.Index
1312
+ sil [ossa] @one : $@convention(thin) <τ_0_0 where τ_0_0 : MyCollection><τ_1_0> (@inout τ_0_0) -> (@out Optional<τ_1_0>, @error any Error)
1313
+ sil [ossa] @startIndex : $@convention(thin) <τ_0_0 where τ_0_0 : MyCollection> (@in_guaranteed τ_0_0) -> @out τ_0_0.Index
1314
+ sil [ossa] @index : $@convention(thin) <τ_0_0 where τ_0_0 : MyCollection> (Int) -> @out τ_0_0.Index
1315
+ sil [ossa] @partition : $@convention(method) <Self where Self : MyCollection> (@inout Self) -> (@out Self.Index, @error any Error) {
1316
+ bb0(%1 : $*Self):
1317
+ %11 = function_ref @one : $@convention(thin) <τ_0_0 where τ_0_0 : MyCollection><τ_1_0> (@inout τ_0_0) -> (@out Optional<τ_1_0>, @error any Error)
1318
+ try_apply %11<Self, Int>(%1) : $@convention(thin) <τ_0_0 where τ_0_0 : MyCollection><τ_1_0> (@inout τ_0_0) -> (@out Optional<τ_1_0>, @error any Error), normal bb1, error bb6
1319
+
1320
+ bb1(%13 : $Optional<Int>):
1321
+ switch_enum %13 : $Optional<Int>, case #Optional.some!enumelt: bb2, case #Optional.none!enumelt: bb3
1322
+
1323
+ bb2(%17 : $Int):
1324
+ %28 = function_ref @index : $@convention(thin) <τ_0_0 where τ_0_0 : MyCollection> (Int) -> @out τ_0_0.Index
1325
+ %29 = apply %28<Self>(%17) : $@convention(thin) <τ_0_0 where τ_0_0 : MyCollection> (Int) -> @out τ_0_0.Index
1326
+ br exit_normal(%29 : $Self.Index)
1327
+
1328
+ bb3:
1329
+ %34 = function_ref @impl : $@convention(method) <τ_0_0 where τ_0_0 : MyCollection> (@inout τ_0_0) -> @out τ_0_0.Index
1330
+ %36 = apply %34<Self>(%1) : $@convention(method) <τ_0_0 where τ_0_0 : MyCollection> (@inout τ_0_0) -> @out τ_0_0.Index
1331
+ br exit_normal(%36 : $Self.Index)
1332
+
1333
+ bb6(%41 : @owned $any Error):
1334
+ br exit_error(%41 : $any Error)
1335
+
1336
+ exit_normal(%39 : @owned $Self.Index):
1337
+ return %39 : $Self.Index
1338
+
1339
+ exit_error(%47 : @owned $any Error):
1340
+ throw %47 : $any Error
1341
+ }
1342
+
1276
1343
sil hidden [ossa] @testBeginApplyDeadYield : $@convention(thin) <T> (@guaranteed TestGeneric<T>) -> () {
1277
1344
bb0(%0 : @guaranteed $TestGeneric<T>):
1278
1345
%2 = class_method %0 : $TestGeneric<T>, #TestGeneric.borrowedGeneric!read : <T> (TestGeneric<T>) -> () -> (), $@yield_once @convention(method) <τ_0_0> (@guaranteed TestGeneric<τ_0_0>) -> @yields @in_guaranteed τ_0_0
@@ -1541,3 +1608,4 @@ bb0(%0 : @guaranteed $T):
1541
1608
destroy_value %3 : $U
1542
1609
return %6 : $U
1543
1610
}
1611
+
0 commit comments