Skip to content

Commit e3b4a7b

Browse files
committed
[NFC] Demoted variable to function scope.
The blocksWithReachedTops variable is only ever used while finding barriers and in a small helper function called at that time. Make it local to that function and make that helper a lambda in that function.
1 parent ab0be3a commit e3b4a7b

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

lib/SILOptimizer/Utils/ShrinkBorrowScope.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ class ShrinkBorrowScope {
5353
llvm::SmallVector<std::pair<SILBasicBlock *, SILInstruction *>>
5454
barrierInstructions;
5555

56-
SmallPtrSet<SILBasicBlock *, 8> blocksWithReachedTops;
5756
SmallPtrSet<SILBasicBlock *, 8> blocksToEndAtTop;
5857

5958
llvm::SmallDenseMap<ApplySite, size_t> transitiveUsesPerApplySite;
@@ -81,12 +80,6 @@ class ShrinkBorrowScope {
8180
void rewrite();
8281
void createEndBorrow(SILInstruction *insertionPoint);
8382

84-
bool reachedTopOfAllSuccessors(SILBasicBlock *block) {
85-
return llvm::all_of(block->getSuccessorBlocks(), [=](auto *successor) {
86-
return blocksWithReachedTops.contains(successor);
87-
});
88-
}
89-
9083
bool isBarrierApply(SILInstruction *instruction) {
9184
// For now, treat every apply (that doesn't use the borrowed value) as a
9285
// barrier.
@@ -248,6 +241,14 @@ void ShrinkBorrowScope::findBarriers() {
248241
// visited.
249242
//
250243
// TODO: Handle loops.
244+
SmallPtrSet<SILBasicBlock *, 8> blocksWithReachedTops;
245+
auto reachedTopOfAllSuccessors =
246+
[&blocksWithReachedTops](SILBasicBlock *block) -> bool {
247+
return llvm::all_of(block->getSuccessorBlocks(), [=](auto *successor) {
248+
return blocksWithReachedTops.contains(successor);
249+
});
250+
};
251+
251252
while (!worklist.empty()) {
252253
auto *block = worklist.pop_back_val();
253254
auto *startingInstruction = startingInstructions.lookup(block);

0 commit comments

Comments
 (0)