@@ -585,62 +585,28 @@ class FullApplySite : public ApplySite {
585
585
llvm_unreachable (" Covered switch isn't covered?!" );
586
586
}
587
587
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).
590
591
// /
591
592
// / The intention is that this abstraction will enable the compiler writer to
592
593
// / ignore whether or not an apply site is a terminator when inserting
593
594
// / instructions after an apply site. This results in eliminating unnecessary
594
595
// / if-else code otherwise required to handle such situations.
595
596
// /
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
597
598
// / /after/ the end_apply/abort_apply, please use instead
598
599
// / 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 ;
614
601
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.
617
604
// /
618
605
// / This is just like insertAfterInvocation except that if the full apply site
619
606
// / is a begin_apply, we pass the insertion points after the end_apply,
620
607
// / abort_apply rather than an insertion point right after the
621
608
// / 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 ;
644
610
645
611
// / Returns true if \p op is an operand that passes an indirect
646
612
// / result argument to the apply site.
0 commit comments