@@ -3444,17 +3444,17 @@ bool SimplifyCFGOpt::speculativelyExecuteBB(BranchInst *BI,
3444
3444
3445
3445
using BlocksSet = SmallPtrSet<BasicBlock *, 8 >;
3446
3446
3447
- static bool reachesUsed (BasicBlock *BB,
3448
- const BlocksSet &UsedInNonLocalBlocksSet,
3447
+ static bool reachesUsed (BasicBlock *BB, BlocksSet &ReachesNonLocalUses,
3449
3448
BlocksSet &VisitedBlocksSet) {
3449
+ if (ReachesNonLocalUses.contains (BB))
3450
+ return true ;
3450
3451
if (!VisitedBlocksSet.insert (BB).second )
3451
3452
return false ;
3452
-
3453
- if (UsedInNonLocalBlocksSet.contains (BB))
3454
- return true ;
3455
3453
for (BasicBlock *Succ : successors (BB))
3456
- if (reachesUsed (Succ, UsedInNonLocalBlocksSet, VisitedBlocksSet))
3454
+ if (reachesUsed (Succ, ReachesNonLocalUses, VisitedBlocksSet)) {
3455
+ ReachesNonLocalUses.insert (BB);
3457
3456
return true ;
3457
+ }
3458
3458
return false ;
3459
3459
}
3460
3460
@@ -3552,8 +3552,8 @@ foldCondBranchOnValueKnownInPredecessorImpl(BranchInst *BI, DomTreeUpdater *DTU,
3552
3552
// Check that the block is small enough and record which non-local blocks use
3553
3553
// values defined in the block.
3554
3554
3555
- BlocksSet UsedInNonLocalBlocksSet ;
3556
- if (!blockIsSimpleEnoughToThreadThrough (BB, UsedInNonLocalBlocksSet ))
3555
+ BlocksSet ReachesNonLocalUses ;
3556
+ if (!blockIsSimpleEnoughToThreadThrough (BB, ReachesNonLocalUses ))
3557
3557
return false ;
3558
3558
3559
3559
for (const auto &Pair : KnownValues) {
@@ -3574,7 +3574,7 @@ foldCondBranchOnValueKnownInPredecessorImpl(BranchInst *BI, DomTreeUpdater *DTU,
3574
3574
3575
3575
// Only revector to RealDest if no values defined in BB are live.
3576
3576
BlocksSet VisitedBlocksSet;
3577
- if (reachesUsed (RealDest, UsedInNonLocalBlocksSet , VisitedBlocksSet))
3577
+ if (reachesUsed (RealDest, ReachesNonLocalUses , VisitedBlocksSet))
3578
3578
continue ;
3579
3579
3580
3580
LLVM_DEBUG ({
0 commit comments