@@ -483,22 +483,16 @@ SILFunction *DifferentiationTransformer::getUnwrappedCurryThunkFunction(
483
483
if (autoCE == nullptr )
484
484
return nullptr ;
485
485
486
- AbstractFunctionDecl *afd = nullptr ;
487
- Expr *expr = autoCE->getUnwrappedCurryThunkExpr ();
488
- switch (autoCE->getThunkKind ()) {
489
- default :
490
- llvm_unreachable (" Only single and double curry thunks are expected" );
491
- case AutoClosureExpr::Kind::SingleCurryThunk:
492
- case AutoClosureExpr::Kind::DoubleCurryThunk:
493
- afd = cast<AbstractFunctionDecl>(cast<ApplyExpr>(expr)->getCalledValue (
494
- /* skipFunctionConversions=*/ true ));
495
- break ;
496
- }
497
- assert (afd);
486
+ auto *ae = dyn_cast_or_null<ApplyExpr>(autoCE->getUnwrappedCurryThunkExpr ());
487
+ if (ae == nullptr )
488
+ return nullptr ;
498
489
490
+ AbstractFunctionDecl *afd = cast<AbstractFunctionDecl>(ae->getCalledValue (
491
+ /* skipFunctionConversions=*/ true ));
499
492
auto silFnIt = afdToSILFn.find (afd);
500
493
if (silFnIt == afdToSILFn.end ()) {
501
- assert (afdToSILFn.empty ());
494
+ assert (afdToSILFn.empty () && " Expect all 'afdToSILFn' cache entries to be "
495
+ " filled at once on the first access attempt" );
502
496
503
497
SILModule *module = getTransform ().getModule ();
504
498
for (SILFunction ¤tFunc : module ->getFunctions ()) {
@@ -518,13 +512,16 @@ SILFunction *DifferentiationTransformer::getUnwrappedCurryThunkFunction(
518
512
if (currentAFD->hasCurriedSelf ()) {
519
513
auto [_, wasEmplace] =
520
514
afdToSILFn.try_emplace (currentAFD, ¤tFunc);
521
- assert (wasEmplace);
515
+ assert (wasEmplace && " Expect all 'afdToSILFn' cache entries to be "
516
+ " filled at once on the first access attempt" );
522
517
}
523
518
}
524
519
}
525
520
526
521
silFnIt = afdToSILFn.find (afd);
527
- assert (silFnIt != afdToSILFn.end ());
522
+ assert (silFnIt != afdToSILFn.end () &&
523
+ " Expect present curry thunk to SIL function mapping after "
524
+ " 'afdToSILFn' cache fill" );
528
525
}
529
526
530
527
return silFnIt->second ;
0 commit comments