Skip to content

Commit e7bc9d0

Browse files
committed
Add a test case for mark_dependence with stored uses.
1 parent d7b9149 commit e7bc9d0

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed
Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,45 @@
11
// RUN: %target-sil-opt %s \
22
// RUN: -o /dev/null \
33
// RUN: -sil-verify-all \
4+
// RUN: -module-name Swift \
45
// RUN: -enable-experimental-feature NonescapableTypes \
5-
// RUN: -enable-experimental-feature NoncopyableGenerics \
6-
// RUN: -lifetime-dependence-diagnostics
6+
// RUN: -enable-experimental-feature NoncopyableGenerics
77

88
// REQUIRES: asserts
99
// REQUIRES: swift_in_compiler
1010

11+
// Test the SIL representation for lifetime depenence.
12+
1113
sil_stage raw
1214

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+
1323
// Test that SILType.isEscpable does not crash on a generic box when NoncopyableGenerics is enabled.
1424
sil shared [serialized] [ossa] @testLocalFunc : $@convention(thin) <T, U> (@guaranteed <τ_0_0> { var τ_0_0 } <U>) -> () {
1525
bb0(%1 : @closureCapture @guaranteed $<τ_0_0> { var τ_0_0 } <U>):
1626
%33 = tuple ()
1727
return %33 : $()
1828
}
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

Comments
 (0)