@@ -55,7 +55,16 @@ class ShrinkBorrowScope {
55
55
llvm::SmallVector<std::pair<SILBasicBlock *, SILInstruction *>>
56
56
barrierInstructions;
57
57
58
- SmallPtrSet<SILBasicBlock *, 8 > blocksToEndAtTop;
58
+ // / Blocks above which the borrow scope cannot be hoisted.
59
+ // /
60
+ // / Consequently, these blocks must begin with end_borrow %borrow.
61
+ // /
62
+ // / Note: These blocks aren't barrier blocks. Rather the borrow scope is
63
+ // / barred from being hoisted out of them. That could happen because
64
+ // / one of its predecessors is a barrier block (i.e. has a successor
65
+ // / which is live) or because one of its predecessors has a terminator
66
+ // / which is itself a deinit barrier.
67
+ SmallPtrSet<SILBasicBlock *, 8 > barredBlocks;
59
68
60
69
llvm::SmallDenseMap<ApplySite, size_t > transitiveUsesPerApplySite;
61
70
@@ -268,7 +277,7 @@ void ShrinkBorrowScope::findBarriers() {
268
277
continue ;
269
278
}
270
279
for (auto *successor : block->getSuccessorBlocks ()) {
271
- blocksToEndAtTop .erase (successor);
280
+ barredBlocks .erase (successor);
272
281
}
273
282
274
283
// We either have processed all successors of block or else it is a block
@@ -294,7 +303,7 @@ void ShrinkBorrowScope::findBarriers() {
294
303
barrierInstructions.push_back ({block, barrier});
295
304
} else {
296
305
deadBlocks.insert (block);
297
- blocksToEndAtTop .insert (block);
306
+ barredBlocks .insert (block);
298
307
for (auto *predecessor : block->getPredecessorBlocks ()) {
299
308
worklist.push_back (predecessor);
300
309
}
@@ -316,7 +325,7 @@ void ShrinkBorrowScope::rewrite() {
316
325
317
326
// Insert the new end_borrow instructions that occur at the beginning of
318
327
// blocks which we couldn't hoist out of.
319
- for (auto *block : blocksToEndAtTop ) {
328
+ for (auto *block : barredBlocks ) {
320
329
auto *insertionPoint = &*block->begin ();
321
330
createEndBorrow (insertionPoint);
322
331
}
0 commit comments