Skip to content

Commit c953da9

Browse files
committed
[SemanticARCOpts] Remove unnecessary borrow scope for @guaranteed function arg when used as a phi operand
1 parent 2974031 commit c953da9

File tree

2 files changed

+1
-17
lines changed

2 files changed

+1
-17
lines changed

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()) {

0 commit comments

Comments
 (0)