mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Merge pull request #85959 from jckarter/borrow-accessor-address-only-non-escapable
SIL: Handle address ReturnInsts from borrow accessors as yielding uses.
This commit is contained in:
@@ -139,7 +139,12 @@ extension AddressUseVisitor {
|
||||
let svi = operand.instruction as! SingleValueInstruction
|
||||
return loadedAddressUse(of: operand, intoValue: svi)
|
||||
|
||||
case is YieldInst:
|
||||
case is YieldInst,
|
||||
// Return should only occur in a borrow or inout accessor, in which case the
|
||||
// returned address should be structurally used as if it were a projected
|
||||
// use in the caller, even though there is no code here in the callee to
|
||||
// formally end the access.
|
||||
is ReturnInst:
|
||||
return yieldedAddressUse(of: operand)
|
||||
|
||||
case let sdai as SourceDestAddrInstruction
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
// RUN: %target-swift-emit-sil -enable-experimental-feature Lifetimes -enable-experimental-feature BorrowAndMutateAccessors -verify %s
|
||||
|
||||
// REQUIRES: swift_feature_Lifetimes
|
||||
// REQUIRES: swift_feature_BorrowAndMutateAccessors
|
||||
|
||||
struct Butt<T: ~Escapable>: ~Escapable {
|
||||
var x: T
|
||||
|
||||
var xx: T {
|
||||
@_lifetime(copy self)
|
||||
borrow {
|
||||
return x
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct Tubb<T>: ~Escapable {
|
||||
var x: T
|
||||
|
||||
@_lifetime(immortal)
|
||||
init() { fatalError() }
|
||||
|
||||
var xx: T {
|
||||
borrow {
|
||||
return x
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user