@@ -377,6 +377,13 @@ void MemoryLifetimeVerifier::initDataflowInBlock(SILBasicBlock *block,
377377 }
378378 break ;
379379 }
380+ case SILInstructionKind::EndBorrowInst: {
381+ auto *ebi = cast<EndBorrowInst>(&I);
382+ if (auto *sbi = dyn_cast<StoreBorrowInst>(ebi->getOperand ())) {
383+ killBits (state, sbi->getDest ());
384+ }
385+ break ;
386+ }
380387 case SILInstructionKind::DestroyAddrInst:
381388 case SILInstructionKind::DeallocStackInst:
382389 killBits (state, I.getOperand (0 ));
@@ -696,8 +703,13 @@ void MemoryLifetimeVerifier::checkBlock(SILBasicBlock *block, Bits &bits) {
696703 break ;
697704 }
698705 case SILInstructionKind::EndBorrowInst: {
699- if (SILValue orig = cast<EndBorrowInst>(&I)->getSingleOriginalValue ())
700- requireBitsSet (bits, orig, &I);
706+ auto *ebi = cast<EndBorrowInst>(&I);
707+ if (auto *sbi = dyn_cast<StoreBorrowInst>(ebi->getOperand ())) {
708+ requireBitsSet (bits, sbi->getDest (), &I);
709+ locations.clearBits (bits, sbi->getDest ());
710+ } else if (auto *lbi = dyn_cast<LoadBorrowInst>(ebi->getOperand ())) {
711+ requireBitsSet (bits, lbi->getOperand (), &I);
712+ }
701713 break ;
702714 }
703715 case SILInstructionKind::UncheckedRefCastAddrInst:
@@ -779,11 +791,7 @@ void MemoryLifetimeVerifier::checkBlock(SILBasicBlock *block, Bits &bits) {
779791 }
780792 case SILInstructionKind::DeallocStackInst: {
781793 SILValue opVal = cast<DeallocStackInst>(&I)->getOperand ();
782- if (isStoreBorrowLocation (opVal)) {
783- requireBitsSet (bits, opVal, &I);
784- } else {
785- requireBitsClear (bits & nonTrivialLocations, opVal, &I);
786- }
794+ requireBitsClear (bits & nonTrivialLocations, opVal, &I);
787795 // Needed to clear any bits of trivial locations (which are not required
788796 // to be zero).
789797 locations.clearBits (bits, opVal);
0 commit comments