@@ -530,6 +530,23 @@ bb0:
530
530
return %7 : $()
531
531
}
532
532
533
+ // CHECK-LABEL: sil @testCastKeypath :
534
+ // CHECK-NOT: keypath
535
+ // CHECK: } // end sil function 'testCastKeypath'
536
+ sil @testCastKeypath : $@convention(thin) () -> () {
537
+ bb0:
538
+ %0 = keypath $WritableKeyPath<Str, Int>, (root $Str; stored_property #Str.a : $Int)
539
+ %c = upcast %0 to $KeyPath<Str, Int>
540
+ %1 = function_ref @closureWithKeypath : $@convention(thin) (Str, @guaranteed KeyPath<Str, Int>) -> Int
541
+ %2 = partial_apply [callee_guaranteed] %1(%c) : $@convention(thin) (Str, @guaranteed KeyPath<Str, Int>) -> Int
542
+ %3 = convert_escape_to_noescape %2 : $@callee_guaranteed (Str) -> Int to $@noescape @callee_guaranteed (Str) -> Int
543
+ %4 = function_ref @calleeWithKeypath : $@convention(thin) (@noescape @callee_guaranteed (Str) -> Int) -> ()
544
+ %5 = apply %4(%3) : $@convention(thin) (@noescape @callee_guaranteed (Str) -> Int) -> ()
545
+ strong_release %2 : $@callee_guaranteed (Str) -> Int
546
+ %7 = tuple ()
547
+ return %7 : $()
548
+ }
549
+
533
550
// CHECK-LABEL: sil shared @$s18closureWithKeypath{{.*}}main3StrVSiTf3npk_n : $@convention(thin) (Str) -> Int {
534
551
// CHECK: [[K:%[0-9]+]] = keypath
535
552
// CHECK: [[F:%[0-9]+]] = function_ref @swift_getAtKeyPath
@@ -566,6 +583,24 @@ bb0:
566
583
return %7 : $()
567
584
}
568
585
586
+ // CHECK-LABEL: sil [ossa] @testCastKeypathOSSA :
587
+ // CHECK-NOT: keypath
588
+ // CHECK: } // end sil function 'testCastKeypathOSSA'
589
+ sil [ossa] @testCastKeypathOSSA : $@convention(thin) () -> () {
590
+ bb0:
591
+ %0 = keypath $WritableKeyPath<Str, Int>, (root $Str; stored_property #Str.a : $Int)
592
+ %c = upcast %0 to $KeyPath<Str, Int>
593
+ %1 = function_ref @closureWithKeypathOSSA : $@convention(thin) (Str, @guaranteed KeyPath<Str, Int>) -> Int
594
+ %2 = partial_apply [callee_guaranteed] %1(%c) : $@convention(thin) (Str, @guaranteed KeyPath<Str, Int>) -> Int
595
+ %3 = convert_escape_to_noescape %2 : $@callee_guaranteed (Str) -> Int to $@noescape @callee_guaranteed (Str) -> Int
596
+ %4 = function_ref @calleeWithKeypath : $@convention(thin) (@noescape @callee_guaranteed (Str) -> Int) -> ()
597
+ %5 = apply %4(%3) : $@convention(thin) (@noescape @callee_guaranteed (Str) -> Int) -> ()
598
+ destroy_value %3 : $@noescape @callee_guaranteed (Str) -> Int
599
+ destroy_value %2 : $@callee_guaranteed (Str) -> Int
600
+ %7 = tuple ()
601
+ return %7 : $()
602
+ }
603
+
569
604
// CHECK-LABEL: sil [ossa] @testKeypathNoescapeOSSA
570
605
// CHECK: [[K:%[0-9]+]] = keypath
571
606
// CHECK: [[C:%[0-9]+]] = function_ref @$s22closureWithKeypathOSSA{{.*}}main3StrVSiTf3npk_n
0 commit comments