@@ -410,3 +410,39 @@ bb2(%error : @owned $any Error):
410
410
destroy_value [dead_end] %nonescaping_nothrower : $@noescape @callee_guaranteed () -> (Int, @error any Error)
411
411
unreachable
412
412
}
413
+
414
+
415
+ sil @nonthrowing : $@convention(thin) (@guaranteed @noescape @callee_guaranteed () -> (Int, @error any Error)) -> ()
416
+ sil @throwsfn : $@convention(thin) () -> ((), @error any Error)
417
+
418
+ // Ensure no ownership verification error
419
+ // CHECK-LABEL: sil [ossa] @testRethrowing : {{.*}} {
420
+ // CHECK: [[NOTHROWER:%[^,]+]] = function_ref @nothrower
421
+ // CHECK: [[THICK_NOTHROWER:%[^,]+]] = thin_to_thick_function [[NOTHROWER]]
422
+ // CHECK: [[THROWING_NOTHROWER:%[^,]+]] = convert_function [[THICK_NOTHROWER]]
423
+ // CHECK: [[NOTHROWER_COPY:%[^,]+]] = copy_value [[THROWING_NOTHROWER]]
424
+ // CHECK: {{bb[0-9]+}}
425
+ // CHECK: destroy_value [[NOTHROWER_COPY]]
426
+ // CHECK: {{bb[0-9]+}}
427
+ // CHECK: destroy_value [[NOTHROWER_COPY]]
428
+ // CHECK-LABEL: } // end sil function 'testRethrowing'
429
+ sil [ossa] @testRethrowing : $@convention(thin) () -> ((), @error any Error) {
430
+ bb0:
431
+ %nothrower = function_ref @nothrower : $@convention(thin) () -> Int
432
+ %thick_nothrower = thin_to_thick_function %nothrower : $@convention(thin) () -> Int to $@callee_guaranteed () -> Int
433
+ %throwing_nothrower = convert_function %thick_nothrower : $@callee_guaranteed () -> Int to $@callee_guaranteed () -> (Int, @error any Error)
434
+ %nonescaping_nothrower = convert_escape_to_noescape [not_guaranteed] %throwing_nothrower : $@callee_guaranteed () -> (Int, @error any Error) to $@noescape @callee_guaranteed () -> (Int, @error any Error)
435
+ %throwsfnref = function_ref @throwsfn : $@convention(thin) () -> ((), @error any Error)
436
+ try_apply %throwsfnref() : $@convention(thin) () -> ((), @error any Error), normal bb1, error bb2
437
+
438
+ bb1(%arg : $()):
439
+ %nonthrower = function_ref @nonthrowing : $@convention(thin) (@guaranteed @noescape @callee_guaranteed () -> (Int, @error any Error)) -> ()
440
+ apply %nonthrower(%nonescaping_nothrower) : $@convention(thin) (@guaranteed @noescape @callee_guaranteed () -> (Int, @error any Error)) -> ()
441
+ destroy_value %nonescaping_nothrower : $@noescape @callee_guaranteed () -> (Int, @error any Error)
442
+ %8 = tuple ()
443
+ return %8 : $()
444
+
445
+ bb2(%error : @owned $any Error):
446
+ destroy_value %nonescaping_nothrower : $@noescape @callee_guaranteed () -> (Int, @error any Error)
447
+ throw %error
448
+ }
0 commit comments