|
1 |
| -// RUN: %target-sil-opt -sil-move-only-object-checker -enable-experimental-feature MoveOnlyClasses -enable-sil-verify-all -move-only-diagnostics-silently-emit-diagnostics %s | %FileCheck %s |
| 1 | +// RUN: %target-sil-opt -sil-move-only-object-checker -enable-experimental-feature MoveOnlyClasses -enable-experimental-feature Lifetimes -enable-sil-verify-all -move-only-diagnostics-silently-emit-diagnostics %s | %FileCheck %s |
2 | 2 |
|
3 | 3 | // REQUIRES: swift_feature_MoveOnlyClasses
|
| 4 | +// REQUIRES: swift_feature_Lifetimes |
4 | 5 |
|
5 | 6 | sil_stage raw
|
6 | 7 |
|
7 | 8 | import Swift
|
8 | 9 |
|
9 | 10 | class Klass: ~Copyable {}
|
10 | 11 |
|
| 12 | +struct NCNE : ~Copyable, ~Escapable {} |
| 13 | + |
| 14 | +struct NCNEHolder : ~Copyable, ~Escapable { |
| 15 | + var ncne: NCNE { |
| 16 | + @_lifetime(borrow self) |
| 17 | + get |
| 18 | + } |
| 19 | +} |
| 20 | + |
11 | 21 | sil @classUseMoveOnlyWithoutEscaping : $@convention(thin) (@guaranteed Klass) -> ()
|
12 | 22 |
|
| 23 | +sil @read_ncne : $@yield_once @convention(method) (@guaranteed NCNEHolder) -> @lifetime(borrow 0) @yields @guaranteed NCNE |
| 24 | +sil @use_ncne : $@convention(thin) (@guaranteed NCNE) -> () |
| 25 | + |
13 | 26 | // CHECK-LABEL: sil [ossa] @chainErrorTest : $@convention(thin) (@guaranteed Klass) -> () {
|
14 | 27 | // CHECK-NOT: copy_value
|
15 | 28 | // CHECK: explicit_copy_value
|
16 | 29 | // CHECK-NOT: copy_value
|
17 | 30 | // CHECK: explicit_copy_value
|
18 |
| -// CHECK-NOT: copy_value |
| 31 | +// CHECK-NOT: copy_valuea |
19 | 32 | // CHECK: } // end sil function 'chainErrorTest'
|
20 | 33 | sil [ossa] @chainErrorTest : $@convention(thin) (@guaranteed Klass) -> () {
|
21 | 34 | bb0(%0 : @guaranteed $Klass):
|
@@ -51,3 +64,27 @@ bb0(%0 : @guaranteed $Klass):
|
51 | 64 | %30 = tuple ()
|
52 | 65 | return %30 : $()
|
53 | 66 | }
|
| 67 | + |
| 68 | +// CHECK-LABEL: sil [ossa] @testCopyOfMarkDep : $@convention(thin) (@guaranteed NCNEHolder) -> () { |
| 69 | +// CHECK-NOT: explicit_copy_value |
| 70 | +// CHECK-NOT: copy_value |
| 71 | +// CHECK-LABEL: } // end sil function 'testCopyOfMarkDep' |
| 72 | +sil [ossa] @testCopyOfMarkDep : $@convention(thin) (@guaranteed NCNEHolder) -> () { |
| 73 | +bb0(%0 : @guaranteed $NCNEHolder): |
| 74 | + %1 = copy_value %0 |
| 75 | + %2 = mark_unresolved_non_copyable_value [no_consume_or_assign] %1 |
| 76 | + debug_value %2, let, name "h", argno 1 |
| 77 | + %4 = function_ref @read_ncne : $@yield_once @convention(method) (@guaranteed NCNEHolder) -> @lifetime(borrow 0) @yields @guaranteed NCNE |
| 78 | + (%5, %6) = begin_apply %4(%2) : $@yield_once @convention(method) (@guaranteed NCNEHolder) -> @lifetime(borrow 0) @yields @guaranteed NCNE |
| 79 | + %7 = mark_dependence [unresolved] %5 on %6 |
| 80 | + %8 = mark_dependence [unresolved] %7 on %2 |
| 81 | + %9 = copy_value %8 |
| 82 | + %10 = mark_unresolved_non_copyable_value [no_consume_or_assign] %9 |
| 83 | + %11 = function_ref @use_ncne : $@convention(thin) (@guaranteed NCNE) -> () |
| 84 | + %12 = apply %11(%10) : $@convention(thin) (@guaranteed NCNE) -> () |
| 85 | + destroy_value %10 |
| 86 | + %14 = end_apply %6 as $() |
| 87 | + destroy_value %2 |
| 88 | + %16 = tuple () |
| 89 | + return %16 |
| 90 | +} |
0 commit comments