File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -391,6 +391,11 @@ bool OwnershipUseVisitor<Impl>::visitGuaranteedUse(Operand *use) {
391
391
return true ;
392
392
393
393
case OperandOwnership::PointerEscape:
394
+ // TODO: Change ProjectBox ownership to InteriorPointer and allow them to
395
+ // take owned values.
396
+ if (isa<ProjectBoxInst>(use->getUser ())) {
397
+ return visitInteriorPointerUses (use);
398
+ }
394
399
if (!asImpl ().handlePointerEscape (use))
395
400
return false ;
396
401
@@ -443,7 +448,8 @@ bool OwnershipUseVisitor<Impl>::visitGuaranteedUse(Operand *use) {
443
448
444
449
template <typename Impl>
445
450
bool OwnershipUseVisitor<Impl>::visitInteriorPointerUses(Operand *use) {
446
- assert (use->getOperandOwnership () == OperandOwnership::InteriorPointer);
451
+ assert (use->getOperandOwnership () == OperandOwnership::InteriorPointer ||
452
+ isa<ProjectBoxInst>(use->getUser ()));
447
453
448
454
if (auto scopedAddress = ScopedAddressValue::forUse (use)) {
449
455
// e.g. client may need to insert end_borrow if scopedAddress is a store_borrow.
Original file line number Diff line number Diff line change @@ -395,3 +395,22 @@ exit:
395
395
%retval = tuple ()
396
396
return %retval : $()
397
397
}
398
+
399
+ // CHECK-LABEL: sil [ossa] @project_box_deadend : {{.*}} {
400
+ // CHECK: bb0([[C:%[^,]+]] :
401
+ // CHECK: [[BOX:%[^,]+]] = alloc_box
402
+ // CHECK: [[BOX_BORROW:%[^,]+]] = begin_borrow [[BOX]]
403
+ // CHECK: [[ADDR:%[^,]+]] = project_box [[BOX_BORROW]]
404
+ // CHECK: store [[C]] to [init] [[ADDR]]
405
+ // CHECK: end_borrow [[BOX_BORROW]]
406
+ // CHECK: unreachable
407
+ // CHECK-LABEL: } // end sil function 'project_box_deadend'
408
+ sil [ossa] @project_box_deadend : $@convention(thin) (@owned C) -> () {
409
+ bb0(%0 : @owned $C):
410
+ %2 = alloc_box ${ var C }
411
+ %3 = begin_borrow %2 : ${ var C }
412
+ specify_test "ossa-lifetime-completion %3"
413
+ %4 = project_box %3 : ${ var C }, 0
414
+ store %0 to [init] %4 : $*C
415
+ unreachable
416
+ }
You can’t perform that action at this time.
0 commit comments