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 {
12851285 case let store as StoringInstruction :
12861286 return walkUp ( newLifetime: store. source)
12871287 case let srcDestInst as SourceDestAddrInstruction :
1288- return walkUp ( newLifetime: srcDestInst. destination )
1288+ return walkUp ( newLifetime: srcDestInst. source )
12891289 case let apply as FullApplySite :
12901290 if let f = apply. referencedFunction, f. isConvertPointerToPointerArgument {
12911291 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
5353
5454sil @initHolder : $@convention(thin) () -> @out Holder
5555sil @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
5657
5758sil @initTrivialHolder : $@convention(thin) () -> @out TrivialHolder
5859sil @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):
218219 %21 = tuple ()
219220 return %21
220221}
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