Correctly terminate inner coroutine for custom vjps

This commit is contained in:
Anton Korobeynikov
2025-09-11 14:50:52 -07:00
parent 3e5206222d
commit 8413073800
2 changed files with 3 additions and 2 deletions

View File

@@ -5395,6 +5395,7 @@ public:
if (forUnwind && CanUnwind) {
SGF.B.createAbortApply(l, ApplyToken);
} else {
// TODO: This is not correct when coroutine has a normal result
SGF.B.createEndApply(l, ApplyToken,
SILType::getEmptyTupleType(SGF.getASTContext()));
}

View File

@@ -6486,7 +6486,7 @@ ManagedValue SILGenFunction::getThunkedAutoDiffLinearMap(
SILType substFnType = linearMapArg->getType().substGenericArgs(
thunkSGF.getModule(), subs, thunk->getTypeExpansionContext());
auto tokenAndCleanups = thunkSGF.emitBeginApplyWithRethrow(
loc, linearMapArg, substFnType,
loc, linearMapArg, substFnType, true,
SubstitutionMap(), arguments, yields);
auto token = std::get<0>(tokenAndCleanups);
auto abortCleanup = std::get<1>(tokenAndCleanups);
@@ -6762,7 +6762,7 @@ SILFunction *SILGenModule::getOrCreateCustomDerivativeThunk(
SmallVector<SILValue, 1> yields;
// Start inner coroutine execution till the suspend point
auto tokenAndCleanups = thunkSGF.emitBeginApplyWithRethrow(
loc, fnRef, substFnType /*fnRef->getType()*/,
loc, fnRef, substFnType /*fnRef->getType()*/, true,
subs, arguments, yields);
auto token = std::get<0>(tokenAndCleanups);
auto abortCleanup = std::get<1>(tokenAndCleanups);