Skip to content

Commit 6cfec91

Browse files
committed
EscapeInfo: handle store_borrow
1 parent c6e3f51 commit 6cfec91

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

SwiftCompilerSources/Sources/Optimizer/Utilities/EscapeUtils.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,9 @@ fileprivate struct EscapeWalker<V: EscapeVisitor> : ValueDefUseWalker,
509509
if path.followStores {
510510
return walkUp(value: store.source, path: path)
511511
}
512+
case let storeBorrow as StoreBorrowInst:
513+
assert(operand == storeBorrow.destinationOperand)
514+
return walkDownUses(ofAddress: storeBorrow, path: path)
512515
case let copyAddr as CopyAddrInst:
513516
if !followLoads(at: path) {
514517
return .continueWalk
@@ -845,6 +848,8 @@ fileprivate struct EscapeWalker<V: EscapeVisitor> : ValueDefUseWalker,
845848
return walkUp(value: rea.instance, path: path.push(.classField, index: rea.fieldIndex).with(knownType: nil))
846849
case let pb as ProjectBoxInst:
847850
return walkUp(value: pb.box, path: path.push(.classField, index: pb.fieldIndex).with(knownType: nil))
851+
case let storeBorrow as StoreBorrowInst:
852+
return walkUp(address: storeBorrow.destination, path: path)
848853
default:
849854
return isEscaping
850855
}

test/SILOptimizer/addr_escape_info.sil

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -845,3 +845,17 @@ bb0(%0 : @owned $XandIntClass):
845845
return %8 : $()
846846
}
847847

848+
// CHECK-LABEL: Address escape information for test_store_borrow:
849+
// CHECK: value: %2 = store_borrow %0 to %1 : $*X // users: %4, %3
850+
// CHECK-NEXT: End function test_store_borrow
851+
sil [ossa] @test_store_borrow : $@convention(thin) (@guaranteed X) -> () {
852+
bb0(%0 : @guaranteed $X):
853+
%1 = alloc_stack $X
854+
%2 = store_borrow %0 to %1 : $*X
855+
fix_lifetime %2 : $*X
856+
end_borrow %2 : $*X
857+
dealloc_stack %1 : $*X
858+
%3 = tuple ()
859+
return %3 : $()
860+
}
861+

0 commit comments

Comments
 (0)