@@ -3457,17 +3457,17 @@ bool SimplifyCFGOpt::speculativelyExecuteBB(BranchInst *BI,
3457
3457
3458
3458
using BlocksSet = SmallPtrSet<BasicBlock *, 8 >;
3459
3459
3460
- static bool reachesUsed (BasicBlock *BB,
3461
- const BlocksSet &UsedInNonLocalBlocksSet,
3460
+ static bool reachesUsed (BasicBlock *BB, BlocksSet &ReachesNonLocalUses,
3462
3461
BlocksSet &VisitedBlocksSet) {
3462
+ if (ReachesNonLocalUses.contains (BB))
3463
+ return true ;
3463
3464
if (!VisitedBlocksSet.insert (BB).second )
3464
3465
return false ;
3465
-
3466
- if (UsedInNonLocalBlocksSet.contains (BB))
3467
- return true ;
3468
3466
for (BasicBlock *Succ : successors (BB))
3469
- if (reachesUsed (Succ, UsedInNonLocalBlocksSet, VisitedBlocksSet))
3467
+ if (reachesUsed (Succ, ReachesNonLocalUses, VisitedBlocksSet)) {
3468
+ ReachesNonLocalUses.insert (BB);
3470
3469
return true ;
3470
+ }
3471
3471
return false ;
3472
3472
}
3473
3473
@@ -3565,8 +3565,8 @@ foldCondBranchOnValueKnownInPredecessorImpl(BranchInst *BI, DomTreeUpdater *DTU,
3565
3565
// Check that the block is small enough and record which non-local blocks use
3566
3566
// values defined in the block.
3567
3567
3568
- BlocksSet UsedInNonLocalBlocksSet ;
3569
- if (!blockIsSimpleEnoughToThreadThrough (BB, UsedInNonLocalBlocksSet ))
3568
+ BlocksSet ReachesNonLocalUses ;
3569
+ if (!blockIsSimpleEnoughToThreadThrough (BB, ReachesNonLocalUses ))
3570
3570
return false ;
3571
3571
3572
3572
for (const auto &Pair : KnownValues) {
@@ -3587,7 +3587,7 @@ foldCondBranchOnValueKnownInPredecessorImpl(BranchInst *BI, DomTreeUpdater *DTU,
3587
3587
3588
3588
// Only revector to RealDest if no values defined in BB are live.
3589
3589
BlocksSet VisitedBlocksSet;
3590
- if (reachesUsed (RealDest, UsedInNonLocalBlocksSet , VisitedBlocksSet))
3590
+ if (reachesUsed (RealDest, ReachesNonLocalUses , VisitedBlocksSet))
3591
3591
continue ;
3592
3592
3593
3593
LLVM_DEBUG ({
0 commit comments