File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -626,6 +626,29 @@ void SILInlineCloner::visitTerminator(SILBasicBlock *BB) {
626626 return ;
627627 }
628628 }
629+
630+ // Modify throw_addr terminators to branch to the error-return BB, rather than
631+ // trying to clone the ThrowAddrInst.
632+ if (auto *TAI = dyn_cast<ThrowAddrInst>(Terminator)) {
633+ SILLocation Loc = getOpLocation (TAI->getLoc ());
634+ switch (Apply.getKind ()) {
635+ case FullApplySiteKind::ApplyInst:
636+ assert (cast<ApplyInst>(Apply)->isNonThrowing ()
637+ && " apply of a function with error result must be non-throwing" );
638+ getBuilder ().createUnreachable (Loc);
639+ return ;
640+ case FullApplySiteKind::BeginApplyInst:
641+ assert (cast<BeginApplyInst>(Apply)->isNonThrowing ()
642+ && " apply of a function with error result must be non-throwing" );
643+ getBuilder ().createUnreachable (Loc);
644+ return ;
645+ case FullApplySiteKind::TryApplyInst:
646+ auto tryAI = cast<TryApplyInst>(Apply);
647+ getBuilder ().createBranch (Loc, tryAI->getErrorBB ());
648+ return ;
649+ }
650+ }
651+
629652 // Otherwise use normal visitor, which clones the existing instruction
630653 // but remaps basic blocks and values.
631654 visit (Terminator);
You can’t perform that action at this time.
0 commit comments