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) {
626
626
return ;
627
627
}
628
628
}
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
+
629
652
// Otherwise use normal visitor, which clones the existing instruction
630
653
// but remaps basic blocks and values.
631
654
visit (Terminator);
You can’t perform that action at this time.
0 commit comments