@@ -585,62 +585,28 @@ class FullApplySite : public ApplySite {
585585 llvm_unreachable (" Covered switch isn't covered?!" );
586586 }
587587
588- // / If this is a terminator apply site, then pass the first instruction of
589- // / each successor to fun. Otherwise, pass std::next(Inst).
588+ // / If this is a terminator apply site, then pass a builder to insert at the
589+ // / first instruction of each successor to \p func. Otherwise, pass a builder
590+ // / to insert at std::next(Inst).
590591 // /
591592 // / The intention is that this abstraction will enable the compiler writer to
592593 // / ignore whether or not an apply site is a terminator when inserting
593594 // / instructions after an apply site. This results in eliminating unnecessary
594595 // / if-else code otherwise required to handle such situations.
595596 // /
596- // / NOTE: We return std::next() for begin_apply. If one wishes to insert code
597+ // / NOTE: We pass std::next() for begin_apply. If one wishes to insert code
597598 // / /after/ the end_apply/abort_apply, please use instead
598599 // / insertAfterFullEvaluation.
599- void insertAfterInvocation (
600- function_ref<void (SILBasicBlock::iterator)> func) const {
601- switch (getKind ()) {
602- case FullApplySiteKind::ApplyInst:
603- case FullApplySiteKind::BeginApplyInst:
604- return func (std::next (getInstruction ()->getIterator ()));
605- case FullApplySiteKind::TryApplyInst:
606- for (auto *succBlock :
607- cast<TermInst>(getInstruction ())->getSuccessorBlocks ()) {
608- func (succBlock->begin ());
609- }
610- return ;
611- }
612- llvm_unreachable (" Covered switch isn't covered" );
613- }
600+ void insertAfterInvocation (function_ref<void (SILBuilder &)> func) const ;
614601
615- // / Pass to func insertion points that are guaranteed to be immediately after
616- // / this full apply site has completely finished executing.
602+ // / Pass a builder with insertion points that are guaranteed to be immediately
603+ // / after this full apply site has completely finished executing.
617604 // /
618605 // / This is just like insertAfterInvocation except that if the full apply site
619606 // / is a begin_apply, we pass the insertion points after the end_apply,
620607 // / abort_apply rather than an insertion point right after the
621608 // / begin_apply. For such functionality, please invoke insertAfterInvocation.
622- void insertAfterFullEvaluation (
623- function_ref<void (SILBasicBlock::iterator)> func) const {
624- switch (getKind ()) {
625- case FullApplySiteKind::ApplyInst:
626- case FullApplySiteKind::TryApplyInst:
627- return insertAfterInvocation (func);
628- case FullApplySiteKind::BeginApplyInst:
629- SmallVector<EndApplyInst *, 2 > endApplies;
630- SmallVector<AbortApplyInst *, 2 > abortApplies;
631- auto *bai = cast<BeginApplyInst>(getInstruction ());
632- bai->getCoroutineEndPoints (endApplies, abortApplies);
633- for (auto *eai : endApplies) {
634- func (std::next (eai->getIterator ()));
635- }
636- for (auto *aai : abortApplies) {
637- func (std::next (aai->getIterator ()));
638- }
639- return ;
640- }
641-
642- llvm_unreachable (" covered switch isn't covered" );
643- }
609+ void insertAfterFullEvaluation (function_ref<void (SILBuilder &)> func) const ;
644610
645611 // / Returns true if \p op is an operand that passes an indirect
646612 // / result argument to the apply site.
0 commit comments