@@ -516,15 +516,20 @@ bb3:
516
516
return %9999 : $()
517
517
}
518
518
519
+ // Rather than eliminate the end_borrow, we just propagate through since
520
+ // branches now act like phis. We could eliminate the begin_borrow scope though,
521
+ // but this pass does not perform that simplification.
522
+ //
519
523
// CHECK-LABEL: sil [ossa] @eliminate_end_borrow_when_propagating_bb_args : $@convention(thin) (@guaranteed Builtin.NativeObject) -> () {
520
- // CHECK-NOT: end_borrow
524
+ // CHECK: %1 = begin_borrow %0
521
525
// CHECK: [[FUNC_REF:%.*]] = function_ref @guaranteed_nativeobject_user
522
- // CHECK-NEXT: apply [[FUNC_REF]](%0 ) :
523
- // CHECK-NOT : end_borrow
526
+ // CHECK-NEXT: apply [[FUNC_REF]](%1 ) :
527
+ // CHECK: end_borrow %1
524
528
// CHECK: } // end sil function 'eliminate_end_borrow_when_propagating_bb_args'
525
529
sil [ossa] @eliminate_end_borrow_when_propagating_bb_args : $@convention(thin) (@guaranteed Builtin.NativeObject) -> () {
526
530
bb0(%0 : @guaranteed $Builtin.NativeObject):
527
- br bb1(%0 : $Builtin.NativeObject)
531
+ %0a = begin_borrow %0 : $Builtin.NativeObject
532
+ br bb1(%0a : $Builtin.NativeObject)
528
533
529
534
bb1(%1 : @guaranteed $Builtin.NativeObject):
530
535
%2 = function_ref @guaranteed_nativeobject_user : $@convention(thin) (@guaranteed Builtin.NativeObject) -> ()
@@ -788,20 +793,20 @@ enum EnumWithB {
788
793
func testit() -> Int
789
794
}
790
795
791
- // Test propagation of guaranteed phi arguments. The nested end_borrow
792
- // must be removed, even with the outer borrow is *not* a function
793
- // argument.
796
+ // Test propagation of guaranteed phi arguments. The nested end_borrow should
797
+ // not be removed since guaranteed phis propagate now.
794
798
//
795
799
// CHECK-LABEL: sil hidden [ossa] @testEliminatePropagateGuaranteedPhiAfterSwitch : $@convention(method) (@guaranteed EnumWithB) -> () {
796
800
// CHECK: bb1([[PHI:%.*]] : @guaranteed $B):
797
- // CHECK-NOT : end_borrow
801
+ // CHECK: end_borrow
798
802
// CHECK-LABEL: } // end sil function 'testEliminatePropagateGuaranteedPhiAfterSwitch'
799
803
sil hidden [ossa] @testEliminatePropagateGuaranteedPhiAfterSwitch : $@convention(method) (@guaranteed EnumWithB) -> () {
800
804
bb0(%0 : @guaranteed $EnumWithB):
801
805
switch_enum %0 : $EnumWithB, case #EnumWithB.A!enumelt.1: bb1
802
806
803
807
bb1(%2 : @guaranteed $B):
804
- br bb3(%2 : $B)
808
+ %2a = begin_borrow %2 : $B
809
+ br bb3(%2a : $B)
805
810
806
811
bb3(%4 : @guaranteed $B):
807
812
%99 = tuple ()
@@ -811,8 +816,9 @@ bb3(%4 : @guaranteed $B):
811
816
812
817
// CHECK-LABEL: sil hidden [ossa] @testEliminatePropagateBeginBorrowGuaranteedPhiAfterSwitch : $@convention(method) (@owned B) -> () {
813
818
// CHECK: [[BORROW:%.*]] = begin_borrow
819
+ // CHECK: bb1:
820
+ // CHECK: bb2:
814
821
// CHECK: end_borrow [[BORROW]]
815
- // CHECK-NOT: end_borrow
816
822
// CHECK-LABEL: } // end sil function 'testEliminatePropagateBeginBorrowGuaranteedPhiAfterSwitch'
817
823
sil hidden [ossa] @testEliminatePropagateBeginBorrowGuaranteedPhiAfterSwitch : $@convention(method) (@owned B) -> () {
818
824
bb0(%0 : @owned $B):
@@ -825,8 +831,6 @@ bb1(%2 : @guaranteed $B):
825
831
bb3(%3 : @guaranteed $B):
826
832
%99 = tuple ()
827
833
end_borrow %3 : $B
828
- end_borrow %2 : $B
829
- end_borrow %1 : $B
830
834
destroy_value %0 : $B
831
835
return %99 : $()
832
836
}
@@ -853,18 +857,18 @@ bb3(%4 : @guaranteed $B):
853
857
// Make sure that we can handle iterated end_borrow.
854
858
//
855
859
// CHECK-LABEL: sil hidden [ossa] @testPropagateGuaranteedPhi : $@convention(method) (@guaranteed B) -> () {
856
- // CHECK-NOT : end_borrow
860
+ // CHECK: end_borrow
857
861
// CHECK-LABEL: } // end sil function 'testPropagateGuaranteedPhi'
858
862
sil hidden [ossa] @testPropagateGuaranteedPhi : $@convention(method) (@guaranteed B) -> () {
859
863
bb0(%0 : @guaranteed $B):
860
- br bb1(%0 : $B)
864
+ %0a = begin_borrow %0 : $B
865
+ br bb1(%0a : $B)
861
866
862
867
bb1(%1 : @guaranteed $B):
863
868
br bb2(%1 : $B)
864
869
865
870
bb2(%2 : @guaranteed $B):
866
871
%99 = tuple ()
867
872
end_borrow %2 : $B
868
- end_borrow %1 : $B
869
873
return %99 : $()
870
874
}
0 commit comments