@@ -21,7 +21,6 @@ class Klass {
21
21
protocol OtherKlass : AnyObject {}
22
22
23
23
sil [ossa] @consume_klass : $@convention(thin) (@owned Klass) -> ()
24
- sil [ossa] @use_klass : $@convention(thin) (@guaranteed Klass) -> ()
25
24
sil [ossa] @get_klass : $@convention(thin) () -> @owned Klass
26
25
27
26
sil [ossa] @unknown : $@convention(thin) () -> ()
@@ -677,6 +676,69 @@ bb8:
677
676
return %25 : $()
678
677
}
679
678
679
+ // CHECK-LABEL: sil [ossa] @redundant_checked_cast_failure_path :
680
+ // CHECK: checked_cast_br
681
+ // CHECK-NOT: checked_cast_br
682
+ // CHECK-LABEL: } // end sil function 'redundant_checked_cast_failure_path'
683
+ sil [ossa] @redundant_checked_cast_failure_path : $@convention(method) (@owned Base) -> () {
684
+ bb0(%0 : @owned $Base):
685
+ %borrow = begin_borrow %0 : $Base
686
+ checked_cast_br %borrow : $Base to Derived, bb1, bb2
687
+
688
+ bb1(%succ1 : @guaranteed $Derived):
689
+ br bbexit
690
+
691
+ bb2(%5 : @guaranteed $Base):
692
+ checked_cast_br %5 : $Base to Derived, bb3, bb4
693
+
694
+ bb3(%9 : @guaranteed $Derived):
695
+ br bbexit
696
+
697
+ bb4(%10 : @guaranteed $Base):
698
+ %m = class_method %10 : $Base, #Base.inner : (Base) -> () -> (), $@convention(method) (@guaranteed Base) -> ()
699
+ apply %m(%10) : $@convention(method) (@guaranteed Base) -> ()
700
+ br bbexit
701
+
702
+ bbexit:
703
+ end_borrow %borrow : $Base
704
+ destroy_value %0 : $Base
705
+ %t = tuple ()
706
+ return %t : $()
707
+ }
708
+
709
+ // CHECK-LABEL: sil [ossa] @redundant_checked_cast_failure_path_not_idom :
710
+ // CHECK: checked_cast_br
711
+ // CHECK-NOT: checked_cast_br
712
+ // CHECK-LABEL: } // end sil function 'redundant_checked_cast_failure_path_not_idom'
713
+ sil [ossa] @redundant_checked_cast_failure_path_not_idom : $@convention(method) (@owned Base) -> () {
714
+ bb0(%0 : @owned $Base):
715
+ %borrow = begin_borrow %0 : $Base
716
+ checked_cast_br %borrow : $Base to Derived, bb1, bb2
717
+
718
+ bb1(%succ1 : @guaranteed $Derived):
719
+ br bbexit
720
+
721
+ bb2(%5 : @guaranteed $Base):
722
+ br bb3(%5 : $Base)
723
+
724
+ bb3(%6 : @guaranteed $Base):
725
+ checked_cast_br %6 : $Base to Derived, bb4, bb5
726
+
727
+ bb4(%9 : @guaranteed $Derived):
728
+ br bbexit
729
+
730
+ bb5(%10 : @guaranteed $Base):
731
+ %m = class_method %10 : $Base, #Base.inner : (Base) -> () -> (), $@convention(method) (@guaranteed Base) -> ()
732
+ apply %m(%10) : $@convention(method) (@guaranteed Base) -> ()
733
+ br bbexit
734
+
735
+ bbexit:
736
+ end_borrow %borrow : $Base
737
+ destroy_value %0 : $Base
738
+ %t = tuple ()
739
+ return %t : $()
740
+ }
741
+
680
742
//!!!TODO: test replacing a guaranteed value with an ownedvalue
681
743
// test borrowOverValue->borrowCopyOverScope path
682
744
0 commit comments