mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
* Disallow stores in the return -> argument path. When walking up in the EscapeUtils, it's allowed to follow stores. Therefore stores wouldn't be handled correctly. * Also make sure that there is a return -> argument path at all Fixes a wrong address-escaping effect in case the called function copies an indirect argument to a newly created object. rdar://105133434
36 lines
769 B
Swift
36 lines
769 B
Swift
// RUN: %target-swift-frontend -O -module-name=test -emit-sil %s | %FileCheck %s
|
|
|
|
protocol P {}
|
|
|
|
public struct S {
|
|
let p: P // force S to be an address-only type
|
|
let i: Int
|
|
}
|
|
|
|
public final class X {
|
|
let s: S
|
|
|
|
init(s: S) {
|
|
self.s = s
|
|
}
|
|
}
|
|
|
|
@inline(never)
|
|
func createX(s: S) -> X {
|
|
return X(s: s)
|
|
}
|
|
|
|
// Test that the load is a barrier for release hoisting and that the strong_release is not hoisted above the load.
|
|
|
|
// CHECK-LABEL: sil @$s4test6testit1sSiAA1SV_tF
|
|
// CHECK: [[X:%[0-9]+]] = apply
|
|
// CHECK: [[R:%[0-9]+]] = load
|
|
// CHECK: strong_release [[X]]
|
|
// CHECK: return [[R]]
|
|
// CHECK: } // end sil function '$s4test6testit1sSiAA1SV_tF'
|
|
public func testit(s: S) -> Int {
|
|
let x = createX(s: s)
|
|
return x.s.i
|
|
}
|
|
|