|
1 | 1 | // RUN: %target-sil-opt %s \
|
2 | 2 | // RUN: -o /dev/null \
|
3 | 3 | // RUN: -sil-verify-all \
|
| 4 | +// RUN: -module-name Swift \ |
4 | 5 | // RUN: -enable-experimental-feature NonescapableTypes \
|
5 |
| -// RUN: -enable-experimental-feature NoncopyableGenerics \ |
6 |
| -// RUN: -lifetime-dependence-diagnostics |
| 6 | +// RUN: -enable-experimental-feature NoncopyableGenerics |
7 | 7 |
|
8 | 8 | // REQUIRES: asserts
|
9 | 9 | // REQUIRES: swift_in_compiler
|
10 | 10 |
|
| 11 | +// Test the SIL representation for lifetime depenence. |
| 12 | + |
11 | 13 | sil_stage raw
|
12 | 14 |
|
| 15 | +class C {} |
| 16 | + |
| 17 | +@_marker public protocol Escapable { } |
| 18 | + |
| 19 | +struct Nonescapable: ~Escapable {} |
| 20 | + |
| 21 | +sil @c_dependence : $@convention(thin) (@guaranteed C) -> _scope(1) @owned Nonescapable |
| 22 | + |
13 | 23 | // Test that SILType.isEscpable does not crash on a generic box when NoncopyableGenerics is enabled.
|
14 | 24 | sil shared [serialized] [ossa] @testLocalFunc : $@convention(thin) <T, U> (@guaranteed <τ_0_0> { var τ_0_0 } <U>) -> () {
|
15 | 25 | bb0(%1 : @closureCapture @guaranteed $<τ_0_0> { var τ_0_0 } <U>):
|
16 | 26 | %33 = tuple ()
|
17 | 27 | return %33 : $()
|
18 | 28 | }
|
| 29 | + |
| 30 | +// Test that ownership verification handles a mark_dependence with a stored use. |
| 31 | +sil [ossa] @test_mark_dependence_store : $@convention(thin) (@owned C) -> () { |
| 32 | +bb0(%0 : @owned $C): |
| 33 | + %stk = alloc_stack [var_decl] $Nonescapable |
| 34 | + %f = function_ref @c_dependence : $@convention(thin) (@guaranteed C) -> _scope(1) @owned Nonescapable |
| 35 | + %c = apply %f(%0) : $@convention(thin) (@guaranteed C) -> _scope(1) @owned Nonescapable |
| 36 | + |
| 37 | + %md = mark_dependence [nonescaping] %c : $Nonescapable on %0 : $C |
| 38 | + store %md to [init] %stk : $*Nonescapable |
| 39 | + |
| 40 | + destroy_addr %stk : $*Nonescapable |
| 41 | + dealloc_stack %stk : $*Nonescapable |
| 42 | + destroy_value %0 : $C |
| 43 | + %28 = tuple () |
| 44 | + return %28 : $() |
| 45 | +} |
0 commit comments