File tree Expand file tree Collapse file tree 3 files changed +17
-6
lines changed
SwiftCompilerSources/Sources/Optimizer/Utilities Expand file tree Collapse file tree 3 files changed +17
-6
lines changed Original file line number Diff line number Diff line change @@ -307,8 +307,8 @@ extension OwnershipUseVisitor {
307
307
}
308
308
// Otherwise, directly visit the scope ending uses.
309
309
//
310
- // TODO: change visitScopeEndingOperands to take a non-escaping
311
- // closure and call ownershipLeafUse directly .
310
+ // TODO: remove this stack by changign visitScopeEndingOperands to
311
+ // take a non-escaping closure that can call ownershipLeafUse.
312
312
var stack = Stack < Operand > ( context)
313
313
defer { stack. deinitialize ( ) }
314
314
_ = borrowInst. visitScopeEndingOperands ( context) {
@@ -448,9 +448,6 @@ extension OwnershipUseVisitor {
448
448
/// MoveValueInst, and Allocation. Then this visitor should assert
449
449
/// that the forward-extended lifetime introducer has no pointer
450
450
/// escaping uses.
451
- ///
452
- /// TODO: Change the operandOwnership of MarkDependenceInst base operand.
453
- /// It should be a borrowing operand, not a pointer escape.
454
451
struct InteriorUseWalker {
455
452
let functionContext : FunctionPassContext
456
453
var context : Context { functionContext }
Original file line number Diff line number Diff line change @@ -658,11 +658,16 @@ OperandOwnershipClassifier::visitMarkDependenceInst(MarkDependenceInst *mdi) {
658
658
return getOwnershipKind ().getForwardingOperandOwnership (
659
659
/* allowUnowned*/ true );
660
660
}
661
- if (getOperandIndex () == MarkDependenceInst::Base && mdi->isNonEscaping ()) {
661
+ if (mdi->isNonEscaping ()) {
662
662
// This creates a "dependent value", just like on-stack partial_apply, which
663
663
// we treat like a borrow.
664
664
return OperandOwnership::Borrow;
665
665
}
666
+ if (mdi->hasUnresolvedEscape ()) {
667
+ // This creates a dependent value that may extend beyond the parent's
668
+ // lifetime.
669
+ return OperandOwnership::UnownedInstantaneousUse;
670
+ }
666
671
// FIXME: Add an end_dependence instruction so we can treat mark_dependence as
667
672
// a borrow of the base (mark_dependence %base -> end_dependence is analogous
668
673
// to a borrow scope).
Original file line number Diff line number Diff line change @@ -1805,6 +1805,15 @@ static bool visitRecursivelyLifetimeEndingUses(
1805
1805
}
1806
1806
continue ;
1807
1807
}
1808
+ if (auto *ret = dyn_cast<ReturnInst>(use->getUser ())) {
1809
+ auto fnTy = ret->getFunction ()->getLoweredFunctionType ();
1810
+ assert (!fnTy->getLifetimeDependenceInfo ().empty ());
1811
+ if (!func (use)) {
1812
+ return false ;
1813
+ }
1814
+ continue ;
1815
+ }
1816
+ // FIXME: Handle store to indirect result
1808
1817
1809
1818
// There shouldn't be any dead-end consumptions of a nonescaping
1810
1819
// partial_apply that don't forward it along, aside from destroy_value.
You can’t perform that action at this time.
0 commit comments