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