File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed
SwiftCompilerSources/Sources/Optimizer/Utilities Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -532,3 +532,25 @@ extension GlobalVariable {
532532 }
533533 }
534534}
535+
536+ extension InstructionRange {
537+ /// Adds the instruction range of a borrow-scope by transitively visiting all (potential) re-borrows.
538+ mutating func insert( borrowScopeOf borrow: BorrowIntroducingInstruction , _ context: some Context ) {
539+ var worklist = ValueWorklist ( context)
540+ defer { worklist. deinitialize ( ) }
541+
542+ worklist. pushIfNotVisited ( borrow)
543+ while let value = worklist. pop ( ) {
544+ for use in value. uses {
545+ switch use. instruction {
546+ case let endBorrow as EndBorrowInst :
547+ self . insert ( endBorrow)
548+ case let branch as BranchInst :
549+ worklist. pushIfNotVisited ( branch. getArgument ( for: use) )
550+ default :
551+ break
552+ }
553+ }
554+ }
555+ }
556+ }
You can’t perform that action at this time.
0 commit comments