Skip to content

Commit 74528ee

Browse files
committed
[NFC] OptUtils: Promote isInLoop to internal.
It will be used by both AllocBoxToStack in addition to StackPromotion and for the same reason.
1 parent f94168c commit 74528ee

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

SwiftCompilerSources/Sources/Optimizer/FunctionPasses/StackPromotion.swift

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -330,17 +330,3 @@ private extension BasicBlockRange {
330330
exits.contains { !deadEndBlocks.isDeadEnd($0) && !$0.hasSinglePredecessor }
331331
}
332332
}
333-
334-
private func isInLoop(block startBlock: BasicBlock, _ context: FunctionPassContext) -> Bool {
335-
var worklist = BasicBlockWorklist(context)
336-
defer { worklist.deinitialize() }
337-
338-
worklist.pushIfNotVisited(contentsOf: startBlock.successors)
339-
while let block = worklist.pop() {
340-
if block == startBlock {
341-
return true
342-
}
343-
worklist.pushIfNotVisited(contentsOf: block.successors)
344-
}
345-
return false
346-
}

SwiftCompilerSources/Sources/Optimizer/Utilities/OptUtils.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,3 +1012,17 @@ func eraseIfDead(functions: [Function], _ context: ModulePassContext) {
10121012
toDelete = remaining
10131013
}
10141014
}
1015+
1016+
func isInLoop(block startBlock: BasicBlock, _ context: FunctionPassContext) -> Bool {
1017+
var worklist = BasicBlockWorklist(context)
1018+
defer { worklist.deinitialize() }
1019+
1020+
worklist.pushIfNotVisited(contentsOf: startBlock.successors)
1021+
while let block = worklist.pop() {
1022+
if block == startBlock {
1023+
return true
1024+
}
1025+
worklist.pushIfNotVisited(contentsOf: block.successors)
1026+
}
1027+
return false
1028+
}

0 commit comments

Comments
 (0)