mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
This was in the first high level ARC instruction proposal, but I have not needed it until now. The use case for this is to ahandle strong_retain_unowned (which takes in an unowned value, asserts it is still alive, performs a strong_retain, and returns the @owned value). This @owned value needs a destroy_value. rdar://29671437
28 lines
1.4 KiB
Plaintext
28 lines
1.4 KiB
Plaintext
// RUN: %target-sil-opt %s | %target-sil-opt | %FileCheck %s
|
|
|
|
import Builtin
|
|
|
|
// CHECK-LABEL: sil @test_copy_release_value
|
|
// CHECK: bb0([[T0:%[0-9]+]] : $Builtin.NativeObject):
|
|
// CHECK-NEXT: [[COPY_RESULT:%.*]] = copy_value [[T0]] : $Builtin.NativeObject
|
|
// CHECK-NEXT: destroy_value [[T0]] : $Builtin.NativeObject
|
|
// CHECK-NEXT: return [[COPY_RESULT]]
|
|
sil @test_copy_release_value : $@convention(thin) (Builtin.NativeObject) -> Builtin.NativeObject {
|
|
bb0(%0 : $Builtin.NativeObject):
|
|
%1 = copy_value %0 : $Builtin.NativeObject
|
|
destroy_value %0 : $Builtin.NativeObject
|
|
return %1 : $Builtin.NativeObject
|
|
}
|
|
|
|
// CHECK-LABEL: sil @test_copy_unowned_value : $@convention(thin) (@owned @sil_unowned Builtin.NativeObject) -> @owned Builtin.NativeObject {
|
|
// CHECK: bb0([[T0:%[0-9]+]] : $@sil_unowned Builtin.NativeObject):
|
|
// CHECK-NEXT: [[COPY_RESULT:%.*]] = copy_unowned_value [[T0]] : $@sil_unowned Builtin.NativeObject
|
|
// CHECK-NEXT: destroy_value [[T0]] : $@sil_unowned Builtin.NativeObject
|
|
// CHECK-NEXT: return [[COPY_RESULT]] : $Builtin.NativeObject
|
|
sil @test_copy_unowned_value : $@convention(thin) (@owned @sil_unowned Builtin.NativeObject) -> @owned Builtin.NativeObject {
|
|
bb0(%0 : $@sil_unowned Builtin.NativeObject):
|
|
%1 = copy_unowned_value %0 : $@sil_unowned Builtin.NativeObject
|
|
destroy_value %0 : $@sil_unowned Builtin.NativeObject
|
|
return %1 : $Builtin.NativeObject
|
|
}
|