@@ -377,6 +377,13 @@ void MemoryLifetimeVerifier::initDataflowInBlock(SILBasicBlock *block,
377
377
}
378
378
break ;
379
379
}
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
+ }
380
387
case SILInstructionKind::DestroyAddrInst:
381
388
case SILInstructionKind::DeallocStackInst:
382
389
killBits (state, I.getOperand (0 ));
@@ -696,8 +703,13 @@ void MemoryLifetimeVerifier::checkBlock(SILBasicBlock *block, Bits &bits) {
696
703
break ;
697
704
}
698
705
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
+ }
701
713
break ;
702
714
}
703
715
case SILInstructionKind::UncheckedRefCastAddrInst:
@@ -779,11 +791,7 @@ void MemoryLifetimeVerifier::checkBlock(SILBasicBlock *block, Bits &bits) {
779
791
}
780
792
case SILInstructionKind::DeallocStackInst: {
781
793
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);
787
795
// Needed to clear any bits of trivial locations (which are not required
788
796
// to be zero).
789
797
locations.clearBits (bits, opVal);
0 commit comments