1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
// 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
}
|