|
1 |
| -// RUN: %target-sil-opt %s \ |
2 |
| -// RUN: --lifetime-dependence-insertion \ |
| 1 | +// RUN: %target-sil-opt \ |
| 2 | +// RUN: -lifetime-dependence-insertion \ |
| 3 | +// RUN: -enable-address-dependencies \ |
3 | 4 | // RUN: -sil-verify-all \
|
4 | 5 | // RUN: -enable-experimental-feature LifetimeDependence \
|
5 |
| -// RUN: 2>&1 | %FileCheck %s |
| 6 | +// RUN: -enable-experimental-feature AddressableParameters \ |
| 7 | +// RUN: -enable-experimental-feature AddressableTypes \ |
| 8 | +// RUN: %s | %FileCheck %s |
6 | 9 |
|
7 | 10 | // REQUIRES: swift_in_compiler
|
8 | 11 | // REQUIRES: swift_feature_LifetimeDependence
|
| 12 | +// REQUIRES: swift_feature_AddressableParameters |
| 13 | +// REQUIRES: swift_feature_AddressableTypes |
9 | 14 |
|
10 | 15 | sil_stage raw
|
11 | 16 |
|
@@ -40,6 +45,8 @@ sil @getPtr : $@convention(thin) () -> @out UnsafeRawPointer
|
40 | 45 | sil @getSpan : $@convention(thin) (@in_guaranteed AnyObject) -> @lifetime(borrow 0) @out NE
|
41 | 46 | sil @getInoutSpan : $@convention(thin) (@inout AnyObject) -> @lifetime(borrow 0) @out NCE
|
42 | 47 |
|
| 48 | +sil @useNE : $@convention(thin) (@guaranteed NE) -> () |
| 49 | + |
43 | 50 | // Check that the inserted dependence is on the 'self' argument, not the temporary borrow.
|
44 | 51 | //
|
45 | 52 | // CHECK-LABEL: sil [available 9999] [ossa] @testSpanProp : $@convention(method) (@guaranteed AnyObject) -> @lifetime(borrow 0) @owned NE {
|
@@ -108,34 +115,60 @@ bb0(%0 : $*AnyObject):
|
108 | 115 | // @_addressable
|
109 | 116 | // =============================================================================
|
110 | 117 |
|
111 |
| -sil hidden [ossa] @addressableArg : $@convention(method) (@in_guaranteed Holder) -> @lifetime(borrow address 0) @owned NE { |
| 118 | +sil [ossa] @loadFromPointer : $@convention(thin) <τ_0_0> (UnsafeRawPointer) -> @out τ_0_0 |
112 | 119 |
|
113 |
| -sil hidden [ossa] @addressableTuple : $@convention(method) (@in_guaranteed (Holder, Holder)) -> @lifetime(borrow address 0) @owned NE { |
| 120 | +sil [ossa] @addressableTrivialArg : $@convention(thin) (@in_guaranteed TrivialHolder) -> @lifetime(borrow address 0) @owned NE |
114 | 121 |
|
115 |
| -sil hidden [ossa] @testAddressableArg : $@convention(thin) (Holder) -> Int { |
116 |
| -bb0(%0 : $Holder): |
| 122 | +// CHECK-LABEL: sil hidden [ossa] @testAddressableTrivialArg : $@convention(thin) (TrivialHolder) -> Int { |
| 123 | +// CHECK: [[ALLOC:%.*]] = alloc_stack $TrivialHolder |
| 124 | +// CHECK: [[APPLY:%.*]] = apply %{{.*}}([[ALLOC]]) : $@convention(thin) (@in_guaranteed TrivialHolder) -> @lifetime(borrow address 0) @owned NE |
| 125 | +// CHECK: mark_dependence [unresolved] [[APPLY]] on [[ALLOC]] |
| 126 | +// CHECK-LABEL: } // end sil function 'testAddressableTrivialArg' |
| 127 | +sil hidden [ossa] @testAddressableTrivialArg : $@convention(thin) (TrivialHolder) -> Int { |
| 128 | +bb0(%0 : $TrivialHolder): |
117 | 129 | debug_value %0, let, name "arg", argno 1
|
118 |
| - %2 = alloc_stack $Holder |
| 130 | + %2 = alloc_stack $TrivialHolder |
119 | 131 | store %0 to [trivial] %2
|
120 |
| - %4 = function_ref @addressableArg : $@convention(thin) (@in_guaranteed Holder) -> @lifetime(borrow address 0) @owned NE |
121 |
| - %5 = apply %4(%2) : $@convention(thin) (@in_guaranteed Holder) -> @lifetime(borrow address 0) @owned NE |
122 |
| - dealloc_stack %2 |
| 132 | + %4 = function_ref @addressableTrivialArg : $@convention(thin) (@in_guaranteed TrivialHolder) -> @lifetime(borrow address 0) @owned NE |
| 133 | + %5 = apply %4(%2) : $@convention(thin) (@in_guaranteed TrivialHolder) -> @lifetime(borrow address 0) @owned NE |
123 | 134 | %7 = move_value [var_decl] %5
|
124 | 135 | debug_value %7, let, name "ne"
|
125 | 136 | %9 = alloc_stack $Int
|
126 | 137 | %10 = begin_borrow %7
|
127 | 138 | %11 = struct_extract %10, #NE.p
|
128 |
| - %12 = metatype $@thin Int.Type |
129 |
| - %13 = metatype $@thick Int.Type |
130 |
| - |
131 |
| - %14 = function_ref @$sSV4load14fromByteOffset2asxSi_xmtlFfA_ : $@convention(thin) <τ_0_0> () -> Int |
132 |
| - %15 = apply %14<Int>() : $@convention(thin) <τ_0_0> () -> Int |
133 |
| - |
134 |
| - %16 = function_ref @$sSV4load14fromByteOffset2asxSi_xmtlF : $@convention(method) <τ_0_0> (Int, @thick τ_0_0.Type, UnsafeRawPointer) -> @out τ_0_0 |
135 |
| - %17 = apply %16<Int>(%9, %15, %13, %11) : $@convention(method) <τ_0_0> (Int, @thick τ_0_0.Type, UnsafeRawPointer) -> @out τ_0_0 |
| 139 | + %16 = function_ref @loadFromPointer : $@convention(thin) <τ_0_0> (UnsafeRawPointer) -> @out τ_0_0 |
| 140 | + %17 = apply %16<Int>(%9, %11) : $@convention(thin) <τ_0_0> (UnsafeRawPointer) -> @out τ_0_0 |
136 | 141 | end_borrow %10
|
137 | 142 | %19 = load [trivial] %9
|
138 | 143 | dealloc_stack %9
|
139 | 144 | destroy_value %7
|
| 145 | + dealloc_stack %2 |
140 | 146 | return %19
|
141 | 147 | }
|
| 148 | + |
| 149 | +sil [ossa] @addressableArg : $@convention(thin) (@in_guaranteed Holder) -> @lifetime(borrow address 0) @owned NE |
| 150 | + |
| 151 | +// CHECK-LABEL: sil hidden [ossa] @testAddressableArg : $@convention(thin) (@guaranteed Holder) -> () { |
| 152 | +// CHECK: bb0(%0 : @guaranteed $Holder): |
| 153 | +// CHECK: [[ALLOC:%.*]] = alloc_stack $Holder |
| 154 | +// CHECK: [[SB:%.*]] = store_borrow %0 to [[ALLOC]] |
| 155 | +// CHECK: [[APPLY:%.*]] = apply %{{.*}}([[SB]]) : $@convention(thin) (@in_guaranteed Holder) -> @lifetime(borrow address 0) @owned NE |
| 156 | +// CHECK: mark_dependence [unresolved] [[APPLY]] on [[SB]] |
| 157 | +// CHECK-LABEL: } // end sil function 'testAddressableArg' |
| 158 | +sil hidden [ossa] @testAddressableArg : $@convention(thin) (@guaranteed Holder) -> () { |
| 159 | +bb0(%0 : @guaranteed $Holder): |
| 160 | + debug_value %0, let, name "arg", argno 1 |
| 161 | + %2 = alloc_stack $Holder |
| 162 | + %3 = store_borrow %0 to %2 |
| 163 | + %4 = function_ref @addressableArg : $@convention(thin) (@in_guaranteed Holder) -> @lifetime(borrow address 0) @owned NE |
| 164 | + %5 = apply %4(%3) : $@convention(thin) (@in_guaranteed Holder) -> @lifetime(borrow address 0) @owned NE |
| 165 | + end_borrow %3 |
| 166 | + %8 = move_value [var_decl] %5 |
| 167 | + debug_value %8, let, name "ne" |
| 168 | + %useNE = function_ref @useNE : $@convention(thin) (@guaranteed NE) -> () |
| 169 | + %18 = apply %useNE(%8) : $@convention(thin) (@guaranteed NE) -> () |
| 170 | + destroy_value %8 |
| 171 | + dealloc_stack %2 |
| 172 | + %99 = tuple () |
| 173 | + return %99 : $() |
| 174 | +} |
0 commit comments