@@ -558,6 +558,29 @@ bb0:
558
558
return %7 : $()
559
559
}
560
560
561
+ // CHECK-LABEL: sil @dontPropagateMulitUseKeyPathInNonOSSA :
562
+ // CHECK: %0 = keypath
563
+ // CHECK: [[U:%.*]] = upcast %0
564
+ // CHECK: [[C:%.*]] = function_ref @closureWithKeypath
565
+ // CHECK: partial_apply [callee_guaranteed] [[C]]([[U]])
566
+ // CHECK: } // end sil function 'dontPropagateMulitUseKeyPathInNonOSSA'
567
+ sil @dontPropagateMulitUseKeyPathInNonOSSA : $@convention(thin) () -> () {
568
+ bb0:
569
+ %0 = keypath $WritableKeyPath<Str, Int>, (root $Str; stored_property #Str.a : $Int)
570
+ %c = upcast %0 to $KeyPath<Str, Int>
571
+ %1 = function_ref @closureWithKeypath : $@convention(thin) (Str, @guaranteed KeyPath<Str, Int>) -> Int
572
+ %2 = partial_apply [callee_guaranteed] %1(%c) : $@convention(thin) (Str, @guaranteed KeyPath<Str, Int>) -> Int
573
+ strong_retain %0
574
+ %3 = convert_escape_to_noescape %2 : $@callee_guaranteed (Str) -> Int to $@noescape @callee_guaranteed (Str) -> Int
575
+ %4 = function_ref @calleeWithKeypath : $@convention(thin) (@noescape @callee_guaranteed (Str) -> Int) -> ()
576
+ %5 = apply %4(%3) : $@convention(thin) (@noescape @callee_guaranteed (Str) -> Int) -> ()
577
+ strong_release %2 : $@callee_guaranteed (Str) -> Int
578
+ strong_release %0
579
+ %7 = tuple ()
580
+ return %7 : $()
581
+ }
582
+
583
+
561
584
// CHECK-LABEL: sil shared @$s18closureWithKeypath{{.*}}main3StrVSiTf3npk_n : $@convention(thin) (Str) -> Int {
562
585
// CHECK: [[K:%[0-9]+]] = keypath
563
586
// CHECK: [[F:%[0-9]+]] = function_ref @swift_getAtKeyPath
@@ -824,6 +847,46 @@ bb0:
824
847
return %12 : $()
825
848
}
826
849
850
+ // CHECK-LABEL: sil [ossa] @testNonConstStruct1 :
851
+ // CHECK: [[S:%.*]] = struct $S
852
+ // CHECK: partial_apply [callee_guaranteed] {{%[0-9]+}}([[S]])
853
+ // CHECK: } // end sil function 'testNonConstStruct1'
854
+ sil [ossa] @testNonConstStruct1 : $@convention(thin) (Int32) -> () {
855
+ bb0(%0 : $Int32):
856
+ %2 = integer_literal $Builtin.Int1, 0
857
+ %3 = struct $Bool (%2)
858
+ %4 = struct $S (%0, %3)
859
+ %5 = function_ref @closureWithStruct : $@convention(thin) (Str, S) -> Builtin.Int32
860
+ %6 = partial_apply [callee_guaranteed] %5(%4) : $@convention(thin) (Str, S) -> Builtin.Int32
861
+ %7 = convert_escape_to_noescape %6 to $@noescape @callee_guaranteed (Str) -> Builtin.Int32
862
+ %8 = function_ref @useIntClosure : $@convention(thin) (@noescape @callee_guaranteed (Str) -> Builtin.Int32) -> ()
863
+ %9 = apply %8(%7) : $@convention(thin) (@noescape @callee_guaranteed (Str) -> Builtin.Int32) -> ()
864
+ destroy_value %7
865
+ destroy_value %6
866
+ %12 = tuple ()
867
+ return %12 : $()
868
+ }
869
+
870
+ // CHECK-LABEL: sil [ossa] @testNonConstStruct2 :
871
+ // CHECK: [[S:%.*]] = struct $S
872
+ // CHECK: partial_apply [callee_guaranteed] {{%[0-9]+}}([[S]])
873
+ // CHECK: } // end sil function 'testNonConstStruct2'
874
+ sil [ossa] @testNonConstStruct2 : $@convention(thin) (Bool) -> () {
875
+ bb0(%0 : $Bool):
876
+ %1 = integer_literal $Builtin.Int32, 3
877
+ %2 = struct $Int32 (%1)
878
+ %4 = struct $S (%2, %0)
879
+ %5 = function_ref @closureWithStruct : $@convention(thin) (Str, S) -> Builtin.Int32
880
+ %6 = partial_apply [callee_guaranteed] %5(%4) : $@convention(thin) (Str, S) -> Builtin.Int32
881
+ %7 = convert_escape_to_noescape %6 to $@noescape @callee_guaranteed (Str) -> Builtin.Int32
882
+ %8 = function_ref @useIntClosure : $@convention(thin) (@noescape @callee_guaranteed (Str) -> Builtin.Int32) -> ()
883
+ %9 = apply %8(%7) : $@convention(thin) (@noescape @callee_guaranteed (Str) -> Builtin.Int32) -> ()
884
+ destroy_value %7
885
+ destroy_value %6
886
+ %12 = tuple ()
887
+ return %12 : $()
888
+ }
889
+
827
890
// CHECK-LABEL: sil shared [ossa] @$s17closureWithStruct4main1SVs5Int32VSbTf3npSSi3Si0_n : $@convention(thin) (Str) -> Builtin.Int32 {
828
891
// CHECK: bb0(%0 : $Str):
829
892
// CHECK: %1 = integer_literal $Builtin.Int32, 3
0 commit comments