|
1 |
| -// RUN: %target-sil-opt -sil-print-types -enable-sil-verify-all %s -mandatory-performance-optimizations | %FileCheck %s |
| 1 | +// RUN: %target-sil-opt -sil-print-types -enable-sil-verify-all %s -mandatory-performance-optimizations -enable-experimental-feature Lifetimes | %FileCheck %s |
2 | 2 |
|
3 | 3 | // REQUIRES: swift_in_compiler
|
| 4 | +// REQUIRES: swift_feature_Lifetimes |
4 | 5 |
|
5 | 6 | sil_stage canonical
|
6 | 7 |
|
@@ -222,6 +223,78 @@ bb0(%0 : $Int, %1 : $@thick Int.Type, %2 : @owned $Builtin.NativeObject):
|
222 | 223 | return %2 : $Builtin.NativeObject
|
223 | 224 | }
|
224 | 225 |
|
| 226 | +sil [no_locks] [perf_constraint] [ossa] @dont_remove_metatype_arg_lifetime : $@convention(thin) (Int, UnsafeRawPointer) -> @lifetime(borrow 1) Span<Int> { |
| 227 | +bb0(%0 : $Int, %1 : $UnsafeRawPointer): |
| 228 | + %3 = metatype $@thick Int.Type |
| 229 | + %7 = function_ref @metatype_arg_lifetime : $@convention(thin) (Int, @thick Int.Type, UnsafeRawPointer) -> @lifetime(borrow 2) Span<Int> |
| 230 | + %8 = apply %7(%0, %3, %1) : $@convention(thin) (Int, @thick Int.Type, UnsafeRawPointer) -> @lifetime(borrow 2) Span<Int> |
| 231 | + return %8 |
| 232 | +} |
| 233 | + |
| 234 | +sil [ossa] @get_span : $@convention(thin) (UnsafeRawPointer) -> @lifetime(borrow 0) Span<Int> |
| 235 | + |
| 236 | +// CHECK-NOT: sil [signature_optimized_thunk] [ossa] @metatype_arg_lifetime : |
| 237 | +sil [ossa] @metatype_arg_lifetime : $@convention(thin) (Int, @thick Int.Type, UnsafeRawPointer) -> @lifetime(borrow 2) Span<Int> { |
| 238 | +bb0(%0 : $Int, %1 : $@thick Int.Type, %2 : $UnsafeRawPointer): |
| 239 | + fix_lifetime %1 : $@thick Int.Type |
| 240 | + %3 = function_ref @get_span : $@convention(thin) (UnsafeRawPointer) -> @lifetime(borrow 0) Span<Int> |
| 241 | + %4 = apply %3(%2) : $@convention(thin) (UnsafeRawPointer) -> @lifetime(borrow 0) Span<Int> |
| 242 | + return %4 |
| 243 | +} |
| 244 | + |
| 245 | +sil [no_locks] [perf_constraint] [ossa] @can_remove_metatype_arg_lifetime : $@convention(thin) (Int, UnsafeRawPointer) -> @lifetime(borrow 1) Span<Int> { |
| 246 | +bb0(%0 : $Int, %1 : $UnsafeRawPointer): |
| 247 | + %3 = metatype $@thick Int.Type |
| 248 | + %7 = function_ref @metatype_arg_lifetime_opt : $@convention(thin) (UnsafeRawPointer, Int, @thick Int.Type) -> @lifetime(borrow 0) Span<Int> |
| 249 | + %8 = apply %7(%1, %0, %3) : $@convention(thin) (UnsafeRawPointer, Int, @thick Int.Type) -> @lifetime(borrow 0) Span<Int> |
| 250 | + return %8 |
| 251 | +} |
| 252 | + |
| 253 | +// CHECK: sil [signature_optimized_thunk] [ossa] @metatype_arg_lifetime_opt : |
| 254 | +sil [ossa] @metatype_arg_lifetime_opt : $@convention(thin) (UnsafeRawPointer, Int, @thick Int.Type) -> @lifetime(borrow 0) Span<Int> { |
| 255 | +bb0(%2 : $UnsafeRawPointer, %0 : $Int, %1 : $@thick Int.Type): |
| 256 | + fix_lifetime %1 : $@thick Int.Type |
| 257 | + %3 = function_ref @get_span : $@convention(thin) (UnsafeRawPointer) -> @lifetime(borrow 0) Span<Int> |
| 258 | + %4 = apply %3(%2) : $@convention(thin) (UnsafeRawPointer) -> @lifetime(borrow 0) Span<Int> |
| 259 | + return %4 |
| 260 | +} |
| 261 | + |
| 262 | +sil [no_locks] [perf_constraint] [ossa] @dont_remove_metatype_arg_lifetime_inout : $@convention(thin) (Int, @lifetime(copy 2) @inout MutableSpan<Int>, @owned MutableSpan<Int>) -> () { |
| 263 | +bb0(%0 : $Int, %1 : $*MutableSpan<Int>, %2 : @owned $MutableSpan<Int>): |
| 264 | + %3 = metatype $@thick Int.Type |
| 265 | + %7 = function_ref @metatype_arg_lifetime_inout : $@convention(thin) (Int, @thick Int.Type, @lifetime(copy 3) @inout MutableSpan<Int>, @owned MutableSpan<Int>) -> () |
| 266 | + %8 = apply %7(%0, %3, %1, %2) : $@convention(thin) (Int, @thick Int.Type, @lifetime(copy 3) @inout MutableSpan<Int>, @owned MutableSpan<Int>) -> () |
| 267 | + %r = tuple () |
| 268 | + return %r |
| 269 | +} |
| 270 | + |
| 271 | +// CHECK-NOT: sil [signature_optimized_thunk] [ossa] @metatype_arg_lifetime_inout : |
| 272 | +sil [ossa] @metatype_arg_lifetime_inout : $@convention(thin) (Int, @thick Int.Type, @lifetime(copy 3) @inout MutableSpan<Int>, @owned MutableSpan<Int>) -> () { |
| 273 | +bb0(%0 : $Int, %1 : $@thick Int.Type, %2 : $*MutableSpan<Int>, %3 : @owned $MutableSpan<Int>): |
| 274 | + fix_lifetime %1 : $@thick Int.Type |
| 275 | + destroy_value %3 |
| 276 | + %r = tuple () |
| 277 | + return %r |
| 278 | +} |
| 279 | + |
| 280 | +sil [no_locks] [perf_constraint] [ossa] @dont_remove_metatype_arg_lifetime_inout_source : $@convention(thin) (Int, @lifetime(copy 2) @inout MutableSpan<Int>, @owned MutableSpan<Int>) -> () { |
| 281 | +bb0(%0 : $Int, %1 : $*MutableSpan<Int>, %2 : @owned $MutableSpan<Int>): |
| 282 | + %3 = metatype $@thick Int.Type |
| 283 | + %7 = function_ref @metatype_arg_lifetime_inout_source : $@convention(thin) (@lifetime(copy 3) @inout MutableSpan<Int>, Int, @thick Int.Type, @owned MutableSpan<Int>) -> () |
| 284 | + %8 = apply %7(%1, %0, %3, %2) : $@convention(thin) (@lifetime(copy 3) @inout MutableSpan<Int>, Int, @thick Int.Type, @owned MutableSpan<Int>) -> () |
| 285 | + %r = tuple () |
| 286 | + return %r |
| 287 | +} |
| 288 | + |
| 289 | +// CHECK-NOT: sil [signature_optimized_thunk] [ossa] @metatype_arg_lifetime_inout_source : |
| 290 | +sil [ossa] @metatype_arg_lifetime_inout_source : $@convention(thin) (@lifetime(copy 3) @inout MutableSpan<Int>, Int, @thick Int.Type, @owned MutableSpan<Int>) -> () { |
| 291 | +bb0(%2 : $*MutableSpan<Int>, %0 : $Int, %1 : $@thick Int.Type, %3 : @owned $MutableSpan<Int>): |
| 292 | + fix_lifetime %1 : $@thick Int.Type |
| 293 | + destroy_value %3 |
| 294 | + %r = tuple () |
| 295 | + return %r |
| 296 | +} |
| 297 | + |
225 | 298 | // CHECK-LABEL: sil [no_locks] [perf_constraint] [ossa] @remove_metatype_arg_throws :
|
226 | 299 | // CHECK: [[F:%.*]] = function_ref @$s19metatype_arg_throwsTf4ndn_n : $@convention(thin) (Int, @owned Builtin.NativeObject) -> (@owned Builtin.NativeObject, @error any Error)
|
227 | 300 | // CHECK: try_apply [[F]](%0, %1) : $@convention(thin) (Int, @owned Builtin.NativeObject) -> (@owned Builtin.NativeObject, @error any Error), normal bb1, error bb2
|
|
0 commit comments