mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Codegen is the same, but `begin_dealloc_ref` consumes the operand and produces a new SSA value. This cleanly splits the liferange to the region before and within the destructor of a class.
74 lines
1.8 KiB
Plaintext
74 lines
1.8 KiB
Plaintext
// RUN: %target-swift-frontend %s -emit-silgen | %FileCheck %s
|
|
|
|
// Check that all reference counting instructions can take the [nonatomic]
|
|
// attribute. SIL parser should be able to parse this attribute and
|
|
// SIL printer should properly print it.
|
|
|
|
sil_stage canonical
|
|
|
|
import Builtin
|
|
import Swift
|
|
import SwiftShims
|
|
|
|
public class C {
|
|
deinit
|
|
init()
|
|
}
|
|
|
|
// foo(C) -> C
|
|
sil [noinline] @_TF28nonatomic_reference_counting3fooFCS_1CS0_ : $@convention(thin) (@owned C) -> @owned C {
|
|
bb0(%0 : $C):
|
|
return %0 : $C
|
|
}
|
|
|
|
// CHECK-LABEL: sil @test_strong_nonatomic_rr
|
|
// CHECK: strong_retain [nonatomic]
|
|
// CHECK: strong_release [nonatomic]
|
|
// CHECK: return
|
|
sil @test_strong_nonatomic_rr: $@convention(thin) () -> @owned C {
|
|
bb0:
|
|
%1 = alloc_ref $C
|
|
strong_retain [nonatomic] %1 : $C
|
|
strong_release [nonatomic] %1 : $C
|
|
return %1 : $C
|
|
}
|
|
|
|
// CHECK-LABEL: sil @test_nonatomic_rr_value
|
|
// CHECK: retain_value [nonatomic]
|
|
// CHECK: release_value [nonatomic]
|
|
// CHECK: return
|
|
sil @test_nonatomic_rr_value: $@convention(thin) () -> @owned C {
|
|
bb0:
|
|
%1 = alloc_ref $C
|
|
retain_value [nonatomic] %1 : $C
|
|
release_value [nonatomic] %1 : $C
|
|
return %1 : $C
|
|
}
|
|
|
|
// CHECK-LABEL: sil @test_unowned_nonatomic_rr
|
|
// CHECK: unowned_retain [nonatomic]
|
|
// CHECK: unowned_release [nonatomic]
|
|
// CHECK: return
|
|
sil @test_unowned_nonatomic_rr: $@convention(thin) () -> () {
|
|
bb0:
|
|
%0 = alloc_ref $C
|
|
%1 = ref_to_unowned %0 : $C to $@sil_unowned C
|
|
unowned_retain [nonatomic] %1 : $@sil_unowned C
|
|
unowned_release [nonatomic] %1 : $@sil_unowned C
|
|
%3 = tuple ()
|
|
return %3 : $()
|
|
}
|
|
|
|
// C.__deallocating_deinit
|
|
sil @_TFC28nonatomic_reference_counting1CD : $@convention(method) (@owned C) -> () {
|
|
bb0(%0 : $C):
|
|
dealloc_ref %0 : $C
|
|
%4 = tuple ()
|
|
return %4 : $()
|
|
}
|
|
|
|
sil_vtable C {
|
|
#C.deinit!deallocator: @_TFC28nonatomic_reference_counting1CD // C.__deallocating_deinit
|
|
}
|
|
|