@@ -483,7 +483,8 @@ emitTypeCheck(SILBasicBlock *FailedTypeCheckBB, SubstitutableType *ParamTy,
483
483
{GenericMTVal, SpecializedMTVal});
484
484
485
485
auto *SuccessBB = Builder.getFunction ().createBasicBlock ();
486
- Builder.createCondBranch (Loc, Cmp, SuccessBB, FailedTypeCheckBB);
486
+ auto *FailBB = createSplitBranchTarget (FailedTypeCheckBB, Builder, Loc);
487
+ Builder.createCondBranch (Loc, Cmp, SuccessBB, FailBB);
487
488
Builder.emitBlock (SuccessBB);
488
489
}
489
490
@@ -510,7 +511,8 @@ void EagerDispatch::emitIsTrivialCheck(SILBasicBlock *FailedTypeCheckBB,
510
511
auto IsPOD = Builder.createBuiltin (Loc, Ctx.getIdentifier (" ispod" ), BoolTy,
511
512
SubMap, {GenericMT});
512
513
auto *SuccessBB = Builder.getFunction ().createBasicBlock ();
513
- Builder.createCondBranch (Loc, IsPOD, SuccessBB, FailedTypeCheckBB);
514
+ auto *FailBB = createSplitBranchTarget (FailedTypeCheckBB, Builder, Loc);
515
+ Builder.createCondBranch (Loc, IsPOD, SuccessBB, FailBB);
514
516
Builder.emitBlock (SuccessBB);
515
517
}
516
518
@@ -542,14 +544,16 @@ void EagerDispatch::emitTrivialAndSizeCheck(SILBasicBlock *FailedTypeCheckBB,
542
544
{ParamSize, LayoutSize});
543
545
544
546
auto *SuccessBB1 = Builder.getFunction ().createBasicBlock ();
545
- Builder.createCondBranch (Loc, Cmp, SuccessBB1, FailedTypeCheckBB);
547
+ auto *FailBB1 = createSplitBranchTarget (FailedTypeCheckBB, Builder, Loc);
548
+ Builder.createCondBranch (Loc, Cmp, SuccessBB1, FailBB1);
546
549
Builder.emitBlock (SuccessBB1);
547
550
// Emit a check that it is a pod object.
548
551
// TODO: Perform this check before all the fixed size checks!
549
552
auto IsPOD = Builder.createBuiltin (Loc, Ctx.getIdentifier (" ispod" ),
550
553
BoolTy, SubMap, { GenericMT });
551
554
auto *SuccessBB2 = Builder.getFunction ().createBasicBlock ();
552
- Builder.createCondBranch (Loc, IsPOD, SuccessBB2, FailedTypeCheckBB);
555
+ auto *FailBB2 = createSplitBranchTarget (FailedTypeCheckBB, Builder, Loc);
556
+ Builder.createCondBranch (Loc, IsPOD, SuccessBB2, FailBB2);
553
557
Builder.emitBlock (SuccessBB2);
554
558
}
555
559
@@ -580,11 +584,11 @@ void EagerDispatch::emitRefCountedObjectCheck(SILBasicBlock *FailedTypeCheckBB,
580
584
{CanBeClass, ClassConst});
581
585
582
586
auto *SuccessBB = Builder.getFunction ().createBasicBlock ();
583
- auto *MayBeCallsCheckBB = Builder.getFunction ().createBasicBlock ();
584
- Builder. createCondBranch (Loc, Cmp1, SuccessBB,
585
- MayBeCallsCheckBB );
587
+ auto *MayBeClassCheckBB = Builder.getFunction ().createBasicBlock ();
588
+ auto *SwiftClassBB = createSplitBranchTarget (SuccessBB, Builder, Loc);
589
+ Builder. createCondBranch (Loc, Cmp1, SwiftClassBB, MayBeClassCheckBB );
586
590
587
- Builder.emitBlock (MayBeCallsCheckBB );
591
+ Builder.emitBlock (MayBeClassCheckBB );
588
592
589
593
auto MayBeClassConst =
590
594
Builder.createIntegerLiteral (Loc, Int8Ty, 2 );
@@ -594,8 +598,9 @@ void EagerDispatch::emitRefCountedObjectCheck(SILBasicBlock *FailedTypeCheckBB,
594
598
{CanBeClass, MayBeClassConst});
595
599
596
600
auto *IsClassCheckBB = Builder.getFunction ().createBasicBlock ();
597
- Builder.createCondBranch (Loc, Cmp2, IsClassCheckBB,
598
- FailedTypeCheckBB);
601
+ auto *FailClassCheckBB =
602
+ createSplitBranchTarget (FailedTypeCheckBB, Builder, Loc);
603
+ Builder.createCondBranch (Loc, Cmp2, IsClassCheckBB, FailClassCheckBB);
599
604
600
605
Builder.emitBlock (IsClassCheckBB);
601
606
@@ -610,7 +615,9 @@ void EagerDispatch::emitRefCountedObjectCheck(SILBasicBlock *FailedTypeCheckBB,
610
615
auto Member = Members[0 ];
611
616
auto BoolValue =
612
617
Builder.emitStructExtract (Loc, IsClassRuntimeCheck, Member, BoolTy);
613
- Builder.createCondBranch (Loc, BoolValue, SuccessBB, FailedTypeCheckBB);
618
+ auto *FailBB = createSplitBranchTarget (FailedTypeCheckBB, Builder, Loc);
619
+ auto *ObjCOrExistentialBB = createSplitBranchTarget (SuccessBB, Builder, Loc);
620
+ Builder.createCondBranch (Loc, BoolValue, ObjCOrExistentialBB, FailBB);
614
621
615
622
Builder.emitBlock (SuccessBB);
616
623
}
0 commit comments