File tree Expand file tree Collapse file tree 2 files changed +26
-3
lines changed Expand file tree Collapse file tree 2 files changed +26
-3
lines changed Original file line number Diff line number Diff line change @@ -290,9 +290,14 @@ bool OwnershipUseVisitor<Impl>::visitInnerBorrowScopeEnd(Operand *borrowEnd) {
290
290
return handleUsePoint (borrowEnd, UseLifetimeConstraint::NonLifetimeEnding);
291
291
}
292
292
case OperandOwnership::DestroyingConsume: {
293
- // partial_apply [on_stack] can introduce borrowing operand and can have destroy_value consumes.
293
+ // partial_apply [on_stack] can introduce borrowing operand and can have
294
+ // destroy_value consumes.
294
295
auto *pai = dyn_cast<PartialApplyInst>(borrowEnd->get ());
295
- assert (pai && pai->isOnStack ());
296
+ // TODO: When we have ForwardingInstruction abstraction, walk the use-def
297
+ // chain to ensure we have a partial_apply [on_stack] def.
298
+ assert (pai && pai->isOnStack () ||
299
+ OwnershipForwardingMixin::get (
300
+ cast<SingleValueInstruction>(borrowEnd->get ())));
296
301
return handleUsePoint (borrowEnd, UseLifetimeConstraint::NonLifetimeEnding);
297
302
}
298
303
Original file line number Diff line number Diff line change @@ -171,7 +171,7 @@ bb10:
171
171
sil @foo : $@convention(thin) (@guaranteed C) -> ()
172
172
173
173
// Ensure no assert fires while handling lifetime end of partial_apply
174
- sil [ossa] @testPartialApplyStack : $@convention(thin) (@guaranteed C) -> () {
174
+ sil [ossa] @testPartialApplyStack1 : $@convention(thin) (@guaranteed C) -> () {
175
175
bb0(%0 : @guaranteed $C):
176
176
test_specification "ossa-lifetime-completion @instruction[0]"
177
177
%8 = copy_value %0 : $C
@@ -194,3 +194,21 @@ bb3:
194
194
return %180 : $()
195
195
}
196
196
197
+ // Ensure no assert fires while handling lifetime end of partial_apply
198
+ sil [ossa] @testPartialApplyStack2 : $@convention(thin) (@guaranteed C) -> () {
199
+ bb0(%0 : @guaranteed $C):
200
+ test_specification "ossa-lifetime-completion @instruction[1]"
201
+ %2 = alloc_stack $C
202
+ %3 = copy_value %0 : $C
203
+ %4 = begin_borrow %3 : $C
204
+ %5 = function_ref @foo : $@convention(thin) (@guaranteed C) -> ()
205
+ %6 = partial_apply [callee_guaranteed] [on_stack] %5(%4) : $@convention(thin) (@guaranteed C) -> ()
206
+ %7 = mark_dependence %6 : $@noescape @callee_guaranteed () -> () on %2 : $*C
207
+ destroy_value %7 : $@noescape @callee_guaranteed () -> ()
208
+ end_borrow %4 : $C
209
+ destroy_value %3 : $C
210
+ dealloc_stack %2 : $*C
211
+ %12 = tuple ()
212
+ return %12 : $()
213
+ }
214
+
You can’t perform that action at this time.
0 commit comments