@@ -1681,11 +1681,11 @@ static bool visitRecursivelyLifetimeEndingUses(
1681
1681
1682
1682
// There shouldn't be any dead-end consumptions of a nonescaping
1683
1683
// partial_apply that don't forward it along, aside from destroy_value.
1684
- assert (use->getUser ()->hasResults ());
1685
- for ( auto result : use->getUser ()->getResults ()) {
1686
- if (!visitRecursivelyLifetimeEndingUses (result, noUsers, func)) {
1687
- return false ;
1688
- }
1684
+ assert (use->getUser ()->hasResults ()
1685
+ && use->getUser ()->getNumResults () == 1 );
1686
+ if (!visitRecursivelyLifetimeEndingUses (use-> getUser ()-> getResult ( 0 ),
1687
+ noUsers, func)) {
1688
+ return false ;
1689
1689
}
1690
1690
}
1691
1691
return true ;
@@ -1721,7 +1721,8 @@ DestroyValueInst::getNonescapingClosureAllocation() const {
1721
1721
if (auto mdi = dyn_cast<MarkDependenceInst>(operand)) {
1722
1722
operand = mdi->getValue ();
1723
1723
continue ;
1724
- } else if (isa<ConvertEscapeToNoEscapeInst>(operand)) {
1724
+ } else if (isa<ConvertEscapeToNoEscapeInst>(operand)
1725
+ || isa<ThinToThickFunctionInst>(operand)) {
1725
1726
// Stop at a conversion from escaping closure, since there's no stack
1726
1727
// allocation in that case.
1727
1728
return nullptr ;
@@ -1739,8 +1740,13 @@ DestroyValueInst::getNonescapingClosureAllocation() const {
1739
1740
// The original partial_apply instruction should only be forwarded
1740
1741
// through one of the above instructions. Anything else should lead us
1741
1742
// to a copy or borrow of the closure from somewhere else.
1742
- // TODO: Assert that this is one of those cases, such as a SILArgument,
1743
- // copy_value, etc.
1743
+ assert ((isa<CopyValueInst>(operand)
1744
+ || isa<SILArgument>(operand)
1745
+ || isa<DifferentiableFunctionInst>(operand)
1746
+ || isa<DifferentiableFunctionExtractInst>(operand)
1747
+ || isa<LoadInst>(operand)
1748
+ || (operand->dump (), false ))
1749
+ && " unexpected forwarding instruction for noescape closure" );
1744
1750
return nullptr ;
1745
1751
}
1746
1752
}
0 commit comments