@@ -157,18 +157,18 @@ static bool diagnoseUnsupportedControlFlow(ADContext &context,
157
157
isa<CheckedCastAddrBranchInst>(term) || isa<TryApplyInst>(term))
158
158
continue ;
159
159
160
- // We can differentiate only indirect yields
160
+ // We can differentiate only indirect yields.
161
161
if (auto *yi = dyn_cast<YieldInst>(term)) {
162
- for ( const auto &val : yi-> getAllOperands ())
163
- if (! yi->getYieldInfoForOperand (val). isAutoDiffSemanticResult ()) {
164
- context. emitNondifferentiabilityError (
165
- term, invoker, diag::autodiff_control_flow_not_supported);
166
- return true ;
167
- }
168
-
162
+ # ifndef NDEBUG
163
+ for ( const auto &val : yi->getAllOperands ()) {
164
+ // This should be diagnosed earlier in VJPCloner.
165
+ assert (yi-> getYieldInfoForOperand (val). isAutoDiffSemanticResult () &&
166
+ " unsupported result " ) ;
167
+ }
168
+ # endif
169
169
continue ;
170
170
}
171
-
171
+
172
172
// If terminator is an unsupported branching terminator, emit an error.
173
173
if (term->isBranch ()) {
174
174
context.emitNondifferentiabilityError (
@@ -562,9 +562,10 @@ emitDerivativeFunctionReference(
562
562
if (resultIndex >= firstYieldResultIndex) {
563
563
auto yieldResultIndex = resultIndex - firstYieldResultIndex;
564
564
auto yield = originalFnTy->getYields ()[yieldResultIndex];
565
- // We can only differentiate indirect yields
566
- if (yield.isAutoDiffSemanticResult ())
567
- resultType = yield.getSILStorageInterfaceType ();
565
+ // We can only differentiate indirect yields. This should be diagnosed
566
+ // earlier in VJPCloner.
567
+ assert (yield.isAutoDiffSemanticResult () && " unsupported result" );
568
+ resultType = yield.getSILStorageInterfaceType ();
568
569
} else if (resultIndex >= firstSemanticParamResultIdx) {
569
570
auto semanticResultParamIdx = resultIndex - firstSemanticParamResultIdx;
570
571
auto semanticResultParam =
0 commit comments