@@ -251,13 +251,12 @@ void CheckedCastBrJumpThreading::Edit::modifyCFGForFailurePreds(
251
251
assert (!Cloner.wasCloned ());
252
252
Cloner.cloneBlock ();
253
253
SILBasicBlock *TargetFailureBB = Cloner.getNewBB ();
254
- auto *TI = TargetFailureBB->getTerminator ();
255
- SILBuilderWithScope Builder (TI);
256
- // This BB copy branches to a FailureBB.
257
- auto *CCBI = cast<CheckedCastBranchInst>(CCBBlock->getTerminator ());
258
- Builder.createBranch (TI->getLoc (), CCBI->getFailureBB ());
259
- TI->eraseFromParent ();
260
- splitIfCriticalEdge (CCBBlock, CCBI->getFailureBB ());
254
+ auto *clonedCCBI =
255
+ cast<CheckedCastBranchInst>(TargetFailureBB->getTerminator ());
256
+ SILBuilderWithScope Builder (clonedCCBI);
257
+ // This BB copy branches to the FailureBB.
258
+ Builder.createBranch (clonedCCBI->getLoc (), clonedCCBI->getFailureBB ());
259
+ clonedCCBI->eraseFromParent ();
261
260
262
261
// Redirect all FailurePreds to the copy of BB.
263
262
for (auto *Pred : FailurePreds) {
@@ -272,9 +271,9 @@ void CheckedCastBrJumpThreading::Edit::modifyCFGForFailurePreds(
272
271
// / a landing basic block for all FailurePreds.
273
272
void CheckedCastBrJumpThreading::Edit::modifyCFGForSuccessPreds (
274
273
BasicBlockCloner &Cloner) {
275
- auto *CCBI = cast<CheckedCastBranchInst>(CCBBlock->getTerminator ());
276
274
277
275
if (InvertSuccess) {
276
+ auto *CCBI = cast<CheckedCastBranchInst>(CCBBlock->getTerminator ());
278
277
SILBuilderWithScope (CCBI).createBranch (CCBI->getLoc (),
279
278
CCBI->getFailureBB ());
280
279
CCBI->eraseFromParent ();
@@ -287,13 +286,14 @@ void CheckedCastBrJumpThreading::Edit::modifyCFGForSuccessPreds(
287
286
assert (!Cloner.wasCloned ());
288
287
Cloner.cloneBlock ();
289
288
SILBasicBlock *TargetSuccessBB = Cloner.getNewBB ();
290
- auto *TI = TargetSuccessBB->getTerminator ();
291
- SILBuilderWithScope Builder (TI);
289
+ auto *clonedCCBI =
290
+ cast<CheckedCastBranchInst>(TargetSuccessBB->getTerminator ());
291
+ SILBuilderWithScope Builder (clonedCCBI);
292
292
// This BB copy branches to SuccessBB.
293
293
// Take argument value from the dominating BB.
294
- Builder.createBranch (TI ->getLoc (), CCBI ->getSuccessBB (), {SuccessArg});
295
- TI-> eraseFromParent ( );
296
- splitIfCriticalEdge (CCBBlock, CCBI-> getSuccessBB () );
294
+ Builder.createBranch (clonedCCBI ->getLoc (), clonedCCBI ->getSuccessBB (),
295
+ {SuccessArg} );
296
+ clonedCCBI-> eraseFromParent ( );
297
297
298
298
// Redirect all SuccessPreds to the copy of BB.
299
299
for (auto *Pred : SuccessPreds) {
@@ -312,6 +312,7 @@ void CheckedCastBrJumpThreading::Edit::modifyCFGForSuccessPreds(
312
312
313
313
// Add an unconditional jump at the end of the block.
314
314
// Take argument value from the dominating BB
315
+ auto *CCBI = cast<CheckedCastBranchInst>(CCBBlock->getTerminator ());
315
316
SILBuilderWithScope (CCBI).createBranch (CCBI->getLoc (), CCBI->getSuccessBB (),
316
317
{SuccessArg});
317
318
CCBI->eraseFromParent ();
0 commit comments