if (PredTBB)
TII->InsertBranch(*PredBB, PredTBB, PredFBB, PredCond, DebugLoc());
- auto Prob = MBPI->getEdgeProbability(PredBB, TailBB);
- PredBB->removeSuccessor(TailBB);
- unsigned NumSuccessors = PredBB->succ_size();
- assert(NumSuccessors <= 1);
- if (NumSuccessors == 0 || *PredBB->succ_begin() != NewTarget)
- PredBB->addSuccessor(NewTarget, Prob);
+ if (!PredBB->isSuccessor(NewTarget))
+ PredBB->replaceSuccessor(TailBB, NewTarget);
+ else {
+ PredBB->removeSuccessor(TailBB, 0);
+ assert(PredBB->succ_size() <= 1);
+ }
TDBBs.push_back(PredBB);
}
!0 = !{!"branch_weights", i32 4, i32 124}
; CHECK: Machine code for function test1:
-; CHECK: Successors according to CFG: BB#1({{[0-9a-fx/= ]+}}3.12%) BB#2({{[0-9a-fx/= ]+}}96.88%)
+; CHECK: Successors according to CFG: BB#2(0x7c000000 / 0x80000000 = 96.88%) BB#1(0x04000000 / 0x80000000 = 3.12%)
@g0 = common global i32 0, align 4