@@ -417,12 +417,42 @@ void swift::replaceBranchTarget(TermInst *t, SILBasicBlock *oldDest,
417
417
return ;
418
418
}
419
419
420
+ case TermKind::TryApplyInst: {
421
+ auto *tai = cast<TryApplyInst>(t);
422
+ SILBasicBlock *normalBB =
423
+ (oldDest == tai->getNormalBB () ? newDest : tai->getNormalBB ());
424
+ SILBasicBlock *errorBB =
425
+ (oldDest == tai->getErrorBB () ? newDest : tai->getErrorBB ());
426
+ SmallVector<SILValue, 8 > args;
427
+ for (SILValue arg : tai->getArguments ()) {
428
+ args.push_back (arg);
429
+ }
430
+ builder.createTryApply ( tai->getLoc (), tai->getCallee (),
431
+ tai->getSubstitutionMap (), args, normalBB, errorBB,
432
+ tai->getSpecializationInfo ());
433
+ tai->eraseFromParent ();
434
+ return ;
435
+ }
436
+
437
+ case TermKind::YieldInst: {
438
+ auto *yi = cast<YieldInst>(t);
439
+ SILBasicBlock *resumeBB =
440
+ (oldDest == yi->getResumeBB () ? newDest : yi->getResumeBB ());
441
+ SILBasicBlock *unwindBB =
442
+ (oldDest == yi->getUnwindBB () ? newDest : yi->getUnwindBB ());
443
+ SmallVector<SILValue, 8 > args;
444
+ for (SILValue arg : yi->getYieldedValues ()) {
445
+ args.push_back (arg);
446
+ }
447
+ builder.createYield (yi->getLoc (), args,resumeBB, unwindBB);
448
+ yi->eraseFromParent ();
449
+ return ;
450
+ }
451
+
420
452
case TermKind::ReturnInst:
421
453
case TermKind::ThrowInst:
422
- case TermKind::TryApplyInst:
423
454
case TermKind::UnreachableInst:
424
455
case TermKind::UnwindInst:
425
- case TermKind::YieldInst:
426
456
llvm_unreachable (
427
457
" Branch target cannot be replaced for this terminator instruction!" );
428
458
}
0 commit comments