mirror of
https://github.com/apple/swift.git
synced 2026-03-04 18:24:35 +01:00
If the '[poison]' flag is set, then all references within this debug value will be overwritten with a sentinel at this point in the program. This is used in debug builds when shortening non-trivial value lifetimes to ensure the debugger cannot inspect invalid memory. `debug_value` instructions with the poison flag are not generated until OSSA islowered. They are not expected to be serialized within the module, and the pipeline is not expected to do any significant code motion after lowering.
46 lines
2.2 KiB
Plaintext
46 lines
2.2 KiB
Plaintext
// RUN: %target-sil-opt %s | %target-sil-opt | %FileCheck %s
|
|
|
|
import Builtin
|
|
|
|
// CHECK-LABEL: sil [ossa] @test_copy_release_value
|
|
// CHECK: bb0([[T0:%[0-9]+]] : @owned $Builtin.NativeObject):
|
|
// CHECK-NEXT: [[COPY_RESULT:%.*]] = copy_value [[T0]] : $Builtin.NativeObject
|
|
// CHECK-NEXT: destroy_value [[T0]] : $Builtin.NativeObject
|
|
// CHECK-NEXT: return [[COPY_RESULT]]
|
|
sil [ossa] @test_copy_release_value : $@convention(thin) (@owned Builtin.NativeObject) -> @owned Builtin.NativeObject {
|
|
bb0(%0 : @owned $Builtin.NativeObject):
|
|
%1 = copy_value %0 : $Builtin.NativeObject
|
|
destroy_value %0 : $Builtin.NativeObject
|
|
return %1 : $Builtin.NativeObject
|
|
}
|
|
|
|
// CHECK-LABEL: sil [ossa] @test_strong_copy_unowned_value : $@convention(thin) (@owned @sil_unowned Builtin.NativeObject) -> @owned Builtin.NativeObject {
|
|
// CHECK: bb0([[T0:%[0-9]+]] : @owned $@sil_unowned Builtin.NativeObject):
|
|
// CHECK-NEXT: [[COPY_RESULT:%.*]] = strong_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 [ossa] @test_strong_copy_unowned_value : $@convention(thin) (@owned @sil_unowned Builtin.NativeObject) -> @owned Builtin.NativeObject {
|
|
bb0(%0 : @owned $@sil_unowned Builtin.NativeObject):
|
|
%1 = strong_copy_unowned_value %0 : $@sil_unowned Builtin.NativeObject
|
|
destroy_value %0 : $@sil_unowned Builtin.NativeObject
|
|
return %1 : $Builtin.NativeObject
|
|
}
|
|
|
|
sil [ossa] @strong_copy_unmanaged_value_test : $@convention(thin) (@sil_unmanaged Builtin.NativeObject) -> @owned Builtin.NativeObject {
|
|
bb0(%0 : $@sil_unmanaged Builtin.NativeObject):
|
|
%1 = strong_copy_unmanaged_value %0 : $@sil_unmanaged Builtin.NativeObject
|
|
return %1 : $Builtin.NativeObject
|
|
}
|
|
|
|
// CHECK-LABEL: sil [ossa] @test_destroy_poison
|
|
// CHECK: bb0([[T0:%[0-9]+]] : @owned $Builtin.NativeObject):
|
|
// CHECK-NEXT: destroy_value [poison] [[T0]] : $Builtin.NativeObject
|
|
// CHECK-NEXT: tuple
|
|
// CHECK-NEXT: return
|
|
sil [ossa] @test_destroy_poison : $@convention(thin) (@owned Builtin.NativeObject) -> () {
|
|
bb0(%0 : @owned $Builtin.NativeObject):
|
|
destroy_value [poison] %0 : $Builtin.NativeObject
|
|
%2 = tuple ()
|
|
return %2 : $()
|
|
}
|