File tree Expand file tree Collapse file tree 2 files changed +32
-5
lines changed
lib/SILOptimizer/Mandatory Expand file tree Collapse file tree 2 files changed +32
-5
lines changed Original file line number Diff line number Diff line change @@ -185,12 +185,9 @@ static void propagateBasicBlockArgs(SILBasicBlock &BB) {
185
185
// this to CCP and trigger another round of copy propagation.
186
186
SILArgument *Arg = *AI;
187
187
188
- // If this argument is guaranteed and Args[Idx] is a SILFunctionArgument,
189
- // delete the end_borrow.
190
- if (Arg->getOwnershipKind () == ValueOwnershipKind::Guaranteed &&
191
- isa<SILFunctionArgument>(Args[Idx])) {
188
+ // If this argument is guaranteed and Args[Idx], delete the end_borrow.
189
+ if (Arg->getOwnershipKind () == ValueOwnershipKind::Guaranteed)
192
190
deleteEndBorrows (Arg);
193
- }
194
191
195
192
// We were able to fold, so all users should use the new folded value.
196
193
Arg->replaceAllUsesWith (Args[Idx]);
Original file line number Diff line number Diff line change @@ -760,3 +760,33 @@ bb2:
760
760
%9999 = tuple()
761
761
return %9999 : $()
762
762
}
763
+
764
+ // Test propagation of guaranteed phi arguments. The nested end_borrow
765
+ // must be removed, even with the outer borrow is *not* a function
766
+ // argument.
767
+
768
+ enum EnumWithB {
769
+ case A(B)
770
+ func testit() -> Int
771
+ }
772
+
773
+ // CHECK-LABEL: sil hidden [ossa] @testPropagateGuaranteedPhi : $@convention(method) (@guaranteed EnumWithB) -> () {
774
+ // CHECK: bb1([[PHI:%.*]] : @guaranteed $B):
775
+ // CHECK: br bb2
776
+ // CHECK: bb2:
777
+ // CHECK: end_borrow [[PHI]] : $B
778
+ // CHECK-NOT: end_borrow
779
+ // CHECK-LABEL: } // end sil function 'testPropagateGuaranteedPhi'
780
+ sil hidden [ossa] @testPropagateGuaranteedPhi : $@convention(method) (@guaranteed EnumWithB) -> () {
781
+ bb0(%0 : @guaranteed $EnumWithB):
782
+ switch_enum %0 : $EnumWithB, case #EnumWithB.A!enumelt.1: bb1
783
+
784
+ bb1(%2 : @guaranteed $B):
785
+ br bb3(%2 : $B)
786
+
787
+ bb3(%4 : @guaranteed $B):
788
+ end_borrow %4 : $B
789
+ end_borrow %2 : $B
790
+ %99 = tuple ()
791
+ return %99 : $()
792
+ }
You can’t perform that action at this time.
0 commit comments