Skip to content

Commit 79565a4

Browse files
authored
Merge pull request #61676 from meg-gupta/followup
Followup for #61505
2 parents cd1d1f8 + 730b513 commit 79565a4

File tree

6 files changed

+3
-41
lines changed

6 files changed

+3
-41
lines changed

lib/SIL/Verifier/SILVerifier.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4881,17 +4881,6 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
48814881
}
48824882

48834883
void checkBranchInst(BranchInst *BI) {
4884-
for (auto arg : BI->getArgs()) {
4885-
auto *borrow = dyn_cast<BeginBorrowInst>(arg);
4886-
if (!borrow) {
4887-
continue;
4888-
}
4889-
auto op = borrow->getOperand();
4890-
if (op->getOwnershipKind() != OwnershipKind::Guaranteed) {
4891-
continue;
4892-
}
4893-
assert(!isGuaranteedForwarding(op));
4894-
}
48954884
require(BI->getArgs().size() == BI->getDestBB()->args_size(),
48964885
"branch has wrong number of arguments for dest bb");
48974886
require(std::equal(BI->getArgs().begin(), BI->getArgs().end(),

lib/SILOptimizer/SemanticARC/OwnedToGuaranteedPhiOpt.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -251,13 +251,6 @@ bool swift::semanticarc::tryConvertOwnedPhisToGuaranteedPhis(Context &ctx) {
251251
while (!incomingValueOperandList.empty()) {
252252
auto incomingValueOperand = incomingValueOperandList.pop_back_val();
253253
SILValue originalValue = originalIncomingValues.pop_back_val();
254-
if (incomingValueOperand.isGuaranteedConsuming() &&
255-
isa<SILFunctionArgument>(originalValue) &&
256-
originalValue->getOwnershipKind() == OwnershipKind::Guaranteed) {
257-
auto loc = RegularLocation::getAutoGeneratedLocation();
258-
SILBuilderWithScope builder(incomingValueOperand.getInst());
259-
originalValue = builder.createBeginBorrow(loc, originalValue);
260-
}
261254
incomingValueOperand.getOperand()->set(originalValue);
262255
}
263256

lib/SILOptimizer/SemanticARC/OwnershipLiveRange.cpp

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -310,16 +310,7 @@ void OwnershipLiveRange::convertJoinedLiveRangePhiToGuaranteed(
310310
InstModCallbacks callbacks) && {
311311

312312
// First convert the phi value itself to be guaranteed.
313-
SILValue phiValue = convertIntroducerToGuaranteed(introducer);
314-
315-
// Then insert end_borrows at each of our destroys if we are consuming. We
316-
// have to convert the phi to guaranteed first since otherwise, the ownership
317-
// check when we create the end_borrows will trigger.
318-
if (auto *phi = dyn_cast<SILPhiArgument>(phiValue)) {
319-
if (!isGuaranteedForwardingPhi(phi)) {
320-
insertEndBorrowsAtDestroys(phiValue, deadEndBlocks, scratch);
321-
}
322-
}
313+
convertIntroducerToGuaranteed(introducer);
323314

324315
// Then eliminate all of the destroys...
325316
while (!destroyingUses.empty()) {

lib/SILOptimizer/Transforms/ConditionForwarding.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -202,14 +202,6 @@ bool ConditionForwarding::tryOptimize(SwitchEnumInst *SEI) {
202202
if (!EI)
203203
return false;
204204

205-
if (getFunction()->hasOwnership() && EI->hasOperand()) {
206-
auto some = EI->getOperand();
207-
if (some->getOwnershipKind() == OwnershipKind::Guaranteed &&
208-
isa<SILFunctionArgument>(some)) {
209-
return false;
210-
}
211-
}
212-
213205
if (CommonBranchBlock && PredPred != CommonBranchBlock)
214206
return false;
215207
CommonBranchBlock = PredPred;

test/SILOptimizer/conditionforwarding_nontrivial_ossa.sil

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,8 @@ bb6:
7171
return %r : $()
7272
}
7373

74-
// Currently, this is not optimized away because enum has @guaranteed function
75-
// argument, which will need a borrow scope before being forwarded.
7674
// CHECK-LABEL: sil [ossa] @simple_forwarding2 :
77-
// CHECK: switch_enum
75+
// CHECK-NOT: switch_enum
7876
// CHECK-LABEL: } // end sil function 'simple_forwarding2'
7977
sil [ossa] @simple_forwarding2 : $@convention(thin) (Builtin.Int1, @guaranteed Klass) -> () {
8078
bb0(%0 : $Builtin.Int1, %1 : @guaranteed $Klass):
@@ -185,6 +183,7 @@ bb6:
185183

186184
// CHECK-LABEL: sil [ossa] @simple_switch_enum_forwarding2 :
187185
// CHECK: switch_enum
186+
// CHECK-NOT: switch_enum
188187
// CHECK-LABEL: } // end sil function 'simple_switch_enum_forwarding2'
189188
sil [ossa] @simple_switch_enum_forwarding2 : $@convention(thin) (@guaranteed E3) -> () {
190189
bb0(%0 : @guaranteed $E3):

test/SILOptimizer/ossa_rauw_tests.sil

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -673,8 +673,6 @@ bb3:
673673
//
674674
// CHECK-LABEL: sil [ossa] @guaranteed_copy_rauw_owned : $@convention(thin) (@guaranteed FakeOptional<Klass>) -> () {
675675
// CHECK-NOT: copy_value
676-
// CHECK: begin_borrow
677-
// CHECK-NOT: copy_value
678676
// CHECK: } // end sil function 'guaranteed_copy_rauw_owned'
679677
sil [ossa] @guaranteed_copy_rauw_owned : $@convention(thin) (@guaranteed FakeOptional<Klass>) -> () {
680678
bb0(%0 : @guaranteed $FakeOptional<Klass>):

0 commit comments

Comments
 (0)