Skip to content

Commit eb3e9b0

Browse files
committed
Update tests for precise lifetime diagnostics.
1 parent 3bee326 commit eb3e9b0

5 files changed

+17
-26
lines changed

test/SILOptimizer/lifetime_dependence_generic.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// RUN: -o /dev/null \
33
// RUN: -verify \
44
// RUN: -sil-verify-all \
5-
// RUN: -module-name test \
65
// RUN: -disable-experimental-parser-round-trip \
76
// RUN: -enable-experimental-feature NonescapableTypes \
87
// RUN: -enable-experimental-feature NoncopyableGenerics \

test/SILOptimizer/lifetime_dependence_param_fail.swift

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,9 @@ struct NE {
4242
}
4343
}
4444

45-
func bv_assign_inout(bv: BV, other: inout BV) {
46-
other = bv // expected-error{{lifetime-dependent value escapes its scope}}
47-
// expected-note @-2 {{it depends on the lifetime of argument 'bv'}}
48-
// expected-note @-2 {{this use causes the lifetime-dependent value to escape}}
45+
func bv_assign_inout(bv: BV, other: inout BV) { // expected-error{{lifetime-dependent variable 'bv' escapes its scope}}
46+
// expected-note @-1 {{it depends on the lifetime of argument 'bv'}}
47+
other = bv // expected-note {{this use causes the lifetime-dependent value to escape}}
4948
}
5049

5150
func bvmut_assign_inout(bv: inout BV, other: inout BV) {
@@ -60,10 +59,9 @@ func bvcons_assign_inout(bv: consuming BV, other: inout BV) {
6059
// expected-note @-2 {{this use causes the lifetime-dependent value to escape}}
6160
}
6261

63-
func bv_assign_field(bv: BV, other: inout NE) {
64-
other.bv = bv // expected-error{{lifetime-dependent value escapes its scope}}
65-
// expected-note @-2 {{it depends on the lifetime of argument 'bv'}}
66-
// expected-note @-2 {{this use causes the lifetime-dependent value to escape}}
62+
func bv_assign_field(bv: BV, other: inout NE) { // expected-error{{lifetime-dependent variable 'bv' escapes its scope}}
63+
// expected-note @-1 {{it depends on the lifetime of argument 'bv'}}
64+
other.bv = bv // expected-note {{this use causes the lifetime-dependent value to escape}}
6765
}
6866

6967
func bvmut_assign_field(bv: inout BV, other: inout NE) {
@@ -78,10 +76,9 @@ func bvcons_assign_field(bv: consuming BV, other: inout NE) {
7876
// expected-note @-2 {{this use causes the lifetime-dependent value to escape}}
7977
}
8078

81-
func bv_capture_escape(bv: BV) -> ()->Int {
82-
return { bv.c } // expected-error{{lifetime-dependent value escapes its scope}}
83-
// expected-note @-2 {{it depends on the lifetime of argument 'bv'}}
84-
// expected-note @-2 {{this use causes the lifetime-dependent value to escape}}
79+
func bv_capture_escape(bv: BV) -> ()->Int { // expected-error{{lifetime-dependent variable 'bv' escapes its scope}}
80+
// expected-note @-1 {{it depends on the lifetime of argument 'bv'}}
81+
return { bv.c } // expected-note {{this use causes the lifetime-dependent value to escape}}
8582
}
8683

8784
// FIXME: Our debug locations on closure captures are incorrect.
@@ -92,10 +89,9 @@ func bvcons_capture_escape(bv: consuming BV) -> ()->Int { // expected-error *{{l
9289
return { bv.c }
9390
}
9491

95-
func bv_capture_escapelet(bv: BV) -> ()->Int {
96-
let closure = { bv.c } // expected-error{{lifetime-dependent value escapes its scope}}
97-
// expected-note @-2 {{it depends on the lifetime of argument 'bv'}}
98-
// expected-note @-2 {{this use causes the lifetime-dependent value to escape}}
92+
func bv_capture_escapelet(bv: BV) -> ()->Int { // expected-error{{lifetime-dependent variable 'bv' escapes its scope}}
93+
// expected-note @-1 {{it depends on the lifetime of argument 'bv'}}
94+
let closure = { bv.c } // expected-note {{this use causes the lifetime-dependent value to escape}}
9995
return closure
10096
}
10197

test/SILOptimizer/lifetime_dependence_scope.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ struct NC : ~Copyable {
3535
}
3636
}
3737

38-
// Rewrite the mark_dependence to depende on the incoming argument rather than the nested access.
38+
// Rewrite the mark_dependence to depend on the incoming argument rather than the nested access.
3939
//
4040
// CHECK-LABEL: sil hidden @$s4test13bv_get_mutate9containerAA2BVVAA2NCVzYls_tF : $@convention(thin) (@inout NC) -> _scope(1) @owned BV {
4141
// CHECK: bb0(%0 : $*NC):

test/SILOptimizer/lifetime_dependence_scope_fixup.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,6 @@ func test3(_ a: Array<Int>) {
120120
}
121121
}
122122

123-
/*
124-
// Currently fails because the lifetime dependence util isn't analyzing a
125-
// def-use chain involving a stack temporary
126123
func test4(_ a: Array<Int>) {
127124
a.withUnsafeBytes {
128125
var x = NCContainer($0, a.count)
@@ -132,7 +129,6 @@ func test4(_ a: Array<Int>) {
132129
consume(view)
133130
}
134131
}
135-
*/
136132

137133
func test5(_ a: Array<Int>) {
138134
a.withUnsafeBytes {
@@ -175,7 +171,6 @@ func test7(_ a: UnsafeRawBufferPointer) {
175171
mutate(&x)
176172
}
177173

178-
/*
179174
// Currently fails because the lifetime dependence util isn't analyzing a
180175
// def-use chain involving a stack temporary
181176
func test8(_ a: Array<Int>) {
@@ -187,7 +182,6 @@ func test8(_ a: Array<Int>) {
187182
consume(view)
188183
}
189184
}
190-
*/
191185

192186
struct Wrapper : ~Escapable {
193187
var _view: View

test/SILOptimizer/lifetime_dependence_util.sil

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,12 @@ entry(%0 : @owned $C, %1 : @owned $D, %2 : @guaranteed $D, %3 : $*D, %4 : $*D):
151151

152152
%inout_arg_mark = mark_dependence [nonescaping] %inguaranteed_arg_mark : $C on %4 : $*D
153153
specify_test "lifetime_dependence_scope %inout_arg_mark"
154+
// @inout arguments are expected to have an access scope.
155+
// A direct dependence on an @inout argument is considered "Unknown".
156+
//
154157
// CHECK-LABEL: dependence_scope: lifetime_dependence_scope with: %inout_arg_mark
155-
// CHECK-NEXT: Caller: %4 = argument of bb0 : $*D
158+
// CHECK-NEXT: Unknown: %4 = argument of bb0 : $*D
156159
// CHECK-NEXT: Dependent: %{{.*}} = mark_dependence [nonescaping] %{{.*}} : $C on %4 : $*D
157-
// CHECK-NEXT: Caller range
158160
// CHECK: dependence_scope: lifetime_dependence_scope with: %inout_arg_mark
159161

160162
destroy_value %inout_arg_mark : $C

0 commit comments

Comments
 (0)