mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
This corresponds to the parameter-passing convention of the Itanium C++ ABI, in which the argument is passed indirectly and possibly modified, but not destroyed, by the callee. @in_cxx is handled the same way as @in in callers and @in_guaranteed in callees. OwnershipModelEliminator emits the call to destroy_addr that is needed to destroy the argument in the caller. rdar://122707697
35 lines
1.5 KiB
Swift
35 lines
1.5 KiB
Swift
// RUN: %target-swiftxx-frontend -I %S/Inputs -emit-silgen %s | %FileCheck --dump-input-filter=all %s
|
|
|
|
// REQUIRES: OS=macosx
|
|
|
|
import Closure
|
|
|
|
// CHECK: sil [ossa] @$s4main11testARCWeakyyF : $@convention(thin) () -> () {
|
|
// CHECK: %[[V0:.*]] = alloc_stack $ARCWeak
|
|
// CHECK: %[[V2:.*]] = function_ref @_ZN7ARCWeakC1Ev : $@convention(c) () -> @out ARCWeak
|
|
// CHECK: %[[V3:.*]] = apply %[[V2]](%[[V0]]) : $@convention(c) () -> @out ARCWeak
|
|
// CHECK: %[[V4:.*]] = function_ref @_Z12cfuncARCWeak7ARCWeak : $@convention(c) (@in ARCWeak) -> ()
|
|
// CHECK: %[[V7:.*]] = apply %[[V4]](%[[V0]]) : $@convention(c) (@in ARCWeak) -> ()
|
|
// CHECK-NOT: destroy_addr
|
|
// CHECK: dealloc_stack %[[V0]] : $*ARCWeak
|
|
|
|
public func testARCWeak() {
|
|
cfuncARCWeak(ARCWeak());
|
|
}
|
|
|
|
// CHECK: sil [ossa] @$s4main26testARCWeakFunctionPointeryyF : $@convention(thin) () -> () {
|
|
// CHECK: %[[V0:.*]] = function_ref @_Z9getFnPtr2v : $@convention(c) () -> @convention(c) (@in ARCWeak) -> ()
|
|
// CHECK: %[[V1:.*]] = apply %[[V0]]() : $@convention(c) () -> @convention(c) (@in ARCWeak) -> ()
|
|
// CHECK: %[[V3:.*]] = alloc_stack $ARCWeak
|
|
// CHECK: %[[V6:.*]] = function_ref @_ZN7ARCWeakC1Ev : $@convention(c) () -> @out ARCWeak
|
|
// CHECK: apply %[[V6]](%[[V3]]) : $@convention(c) () -> @out ARCWeak
|
|
// CHECK: apply %[[V1]](%[[V3]]) : $@convention(c) (@in ARCWeak) -> ()
|
|
// CHECK-NEXT: dealloc_stack %[[V3]] : $*ARCWeak
|
|
// CHECK-NEXT: %[[V9:.*]] = tuple ()
|
|
// CHECK-NEXT: return %[[V9]] : $()
|
|
|
|
public func testARCWeakFunctionPointer() {
|
|
let f = getFnPtr2()
|
|
f(ARCWeak())
|
|
}
|