File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed
SwiftCompilerSources/Sources/Optimizer/Utilities
test/SILOptimizer/lifetime_dependence Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -1285,7 +1285,7 @@ extension LifetimeDependenceUseDefAddressWalker {
1285
1285
case let store as StoringInstruction :
1286
1286
return walkUp ( newLifetime: store. source)
1287
1287
case let srcDestInst as SourceDestAddrInstruction :
1288
- return walkUp ( newLifetime: srcDestInst. destination )
1288
+ return walkUp ( newLifetime: srcDestInst. source )
1289
1289
case let apply as FullApplySite :
1290
1290
if let f = apply. referencedFunction, f. isConvertPointerToPointerArgument {
1291
1291
return walkUp ( newLifetime: apply. parameterOperands [ 0 ] . value)
Original file line number Diff line number Diff line change @@ -53,6 +53,7 @@ sil @reborrowNE : $@convention(thin) (@guaranteed NE) -> @lifetime(borrow 0) @ow
53
53
54
54
sil @initHolder : $@convention(thin) () -> @out Holder
55
55
sil @getNE : $@convention(thin) (@in_guaranteed Holder) -> @lifetime(borrow address_for_deps 0) @owned NE
56
+ sil @getNEIndirect : $@convention(thin) (@in_guaranteed Holder) -> @lifetime(borrow address_for_deps 0) @out NE
56
57
57
58
sil @initTrivialHolder : $@convention(thin) () -> @out TrivialHolder
58
59
sil @getTrivialNE : $@convention(thin) (@in_guaranteed TrivialHolder) -> @lifetime(borrow address_for_deps 0) @owned NE
@@ -218,3 +219,27 @@ bb0(%0 : $*T, %1 : $@thick T.Type):
218
219
%21 = tuple ()
219
220
return %21
220
221
}
222
+
223
+ // Test VariableDefUseWalker: initialization with copy_addr.
224
+ sil shared [thunk] [ossa] @testCopyInit : $@convention(thin) (@in_guaranteed Holder) -> @out NE {
225
+ bb0(%0 : $*NE, %1 : $*Holder):
226
+ %2 = alloc_stack $Holder
227
+ copy_addr %1 to [init] %2
228
+ %4 = load [take] %2
229
+ %5 = alloc_stack $Holder
230
+ %6 = store_borrow %4 to %5
231
+ %7 = alloc_stack $NE // expected-error {{lifetime-dependent value escapes its scope}}
232
+
233
+ %8 = function_ref @getNEIndirect : $@convention(thin) (@in_guaranteed Holder) -> @lifetime(borrow address_for_deps 0) @out NE
234
+ %9 = apply %8(%7, %6) : $@convention(thin) (@in_guaranteed Holder) -> @lifetime(borrow address_for_deps 0) @out NE
235
+ mark_dependence_addr [unresolved] %7 on %6
236
+ %11 = load [take] %7
237
+ store %11 to [init] %0 // expected-note {{this use causes the lifetime-dependent value to escape}}
238
+ end_borrow %6
239
+ dealloc_stack %7
240
+ dealloc_stack %5
241
+ destroy_value %4
242
+ dealloc_stack %2
243
+ %18 = tuple ()
244
+ return %18
245
+ }
You can’t perform that action at this time.
0 commit comments