@@ -89,6 +89,9 @@ class MemoryLifetimeVerifier {
89
89
// / Register the destination address of a store_borrow as borrowed location.
90
90
void registerStoreBorrowLocation (SILValue addr);
91
91
92
+ // / Registers all store_borrow instructions in a block.
93
+ void registerStoreBorrowsInBlock (SILBasicBlock *block);
94
+
92
95
// / Handles locations of the predecessor's terminator, which are only valid
93
96
// / in \p block.
94
97
// / Example: @out results of try_apply. They are only valid in the
@@ -286,6 +289,13 @@ void MemoryLifetimeVerifier::registerStoreBorrowLocation(SILValue addr) {
286
289
}
287
290
}
288
291
292
+ void MemoryLifetimeVerifier::registerStoreBorrowsInBlock (SILBasicBlock *block) {
293
+ for (SILInstruction &inst : *block) {
294
+ if (auto *sbi = dyn_cast<StoreBorrowInst>(&inst))
295
+ registerStoreBorrowLocation (sbi->getDest ());
296
+ }
297
+ }
298
+
289
299
void MemoryLifetimeVerifier::initDataflow (BitDataflow &dataFlow) {
290
300
// Initialize the entry and exit sets to all-bits-set. Except for the function
291
301
// entry.
@@ -579,7 +589,6 @@ void MemoryLifetimeVerifier::checkBlock(SILBasicBlock *block, Bits &bits) {
579
589
case SILInstructionKind::StoreBorrowInst: {
580
590
SILValue destAddr = cast<StoreBorrowInst>(&I)->getDest ();
581
591
locations.setBits (bits, destAddr);
582
- registerStoreBorrowLocation (destAddr);
583
592
break ;
584
593
}
585
594
case SILInstructionKind::CopyAddrInst: {
@@ -764,6 +773,7 @@ void MemoryLifetimeVerifier::verify() {
764
773
locations.handleSingleBlockLocations ([this ](SILBasicBlock *block) {
765
774
storeBorrowLocations.clear ();
766
775
Bits bits (locations.getNumLocations ());
776
+ registerStoreBorrowsInBlock (block);
767
777
checkBlock (block, bits);
768
778
});
769
779
}
0 commit comments