@@ -636,22 +636,6 @@ swift::castValueToABICompatibleType(SILBuilder *builder, SILLocation loc,
636
636
auto *noneBB = builder->getFunction ().createBasicBlockAfter (someBB);
637
637
638
638
auto *phi = contBB->createPhiArgument (destTy, value->getOwnershipKind ());
639
- if (phi->getOwnershipKind () == OwnershipKind::Guaranteed) {
640
- auto createEndBorrow = [&](SILBasicBlock::iterator insertPt) {
641
- builder->setInsertionPoint (insertPt);
642
- builder->createEndBorrow (loc, phi);
643
- };
644
- for (SILInstruction *user : usePoints) {
645
- if (isa<TermInst>(user)) {
646
- assert (!isa<BranchInst>(user) && " no branch as guaranteed use point" );
647
- for (auto *succBB : user->getParent ()->getSuccessorBlocks ()) {
648
- createEndBorrow (succBB->begin ());
649
- }
650
- continue ;
651
- }
652
- createEndBorrow (std::next (user->getIterator ()));
653
- }
654
- }
655
639
656
640
SmallVector<std::pair<EnumElementDecl *, SILBasicBlock *>, 1 > caseBBs;
657
641
caseBBs.push_back (std::make_pair (someDecl, someBB));
@@ -677,17 +661,11 @@ swift::castValueToABICompatibleType(SILBuilder *builder, SILLocation loc,
677
661
// rewrapped Optional.
678
662
SILValue someValue =
679
663
builder->createOptionalSome (loc, castedUnwrappedValue, destTy);
680
- if (phi->getOwnershipKind () == OwnershipKind::Guaranteed) {
681
- someValue = builder->createBeginBorrow (loc, someValue);
682
- }
683
664
builder->createBranch (loc, contBB, {someValue});
684
665
685
666
// Handle the None case.
686
667
builder->setInsertionPoint (noneBB);
687
668
SILValue noneValue = builder->createOptionalNone (loc, destTy);
688
- if (phi->getOwnershipKind () == OwnershipKind::Guaranteed) {
689
- noneValue = builder->createBeginBorrow (loc, noneValue);
690
- }
691
669
builder->createBranch (loc, contBB, {noneValue});
692
670
builder->setInsertionPoint (contBB->begin ());
693
671
0 commit comments