Skip to content

Commit 4eea762

Browse files
committed
[NFC] [ShrinkBorrowScope] Moved check.
Previously, the body--of the loop that iterated the instructions in the block--contained the check that the instruction over which hoisting might be done is the introducer. Here, that check is moved into tryHoistOverInstruction. Now that function and its other caller, canHoistOverInstruction, will return the right value (false) if they are ever called with the introducer (though that could not happen without this change).
1 parent 650b03c commit 4eea762

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

lib/SILOptimizer/Utils/ShrinkBorrowScope.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,9 @@ class ShrinkBorrowScope {
147147
}
148148

149149
bool tryHoistOverInstruction(SILInstruction *instruction, bool rewrite = true) {
150+
if (instruction == introducer) {
151+
return false;
152+
}
150153
if (users.contains(instruction)) {
151154
if (auto apply = ApplySite::isa(instruction)) {
152155
SmallVector<int, 2> rewritableArgumentIndices;
@@ -308,10 +311,6 @@ void ShrinkBorrowScope::findBarriers() {
308311
}
309312
SILInstruction *barrier = nullptr;
310313
while ((instruction = instruction->getPreviousInstruction())) {
311-
if (instruction == introducer) {
312-
barrier = instruction;
313-
break;
314-
}
315314
if (!tryHoistOverInstruction(instruction)) {
316315
barrier = instruction;
317316
break;

0 commit comments

Comments
 (0)