Skip to content

Commit 828e5b5

Browse files
committed
If we determine a block reaches non-local uses, record that result.
Signed-off-by: John Lu <[email protected]>
1 parent 9b533b7 commit 828e5b5

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

llvm/lib/Transforms/Utils/SimplifyCFG.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3444,17 +3444,17 @@ bool SimplifyCFGOpt::speculativelyExecuteBB(BranchInst *BI,
34443444

34453445
using BlocksSet = SmallPtrSet<BasicBlock *, 8>;
34463446

3447-
static bool reachesUsed(BasicBlock *BB,
3448-
const BlocksSet &UsedInNonLocalBlocksSet,
3447+
static bool reachesUsed(BasicBlock *BB, BlocksSet &ReachesNonLocalUses,
34493448
BlocksSet &VisitedBlocksSet) {
3449+
if (ReachesNonLocalUses.contains(BB))
3450+
return true;
34503451
if (!VisitedBlocksSet.insert(BB).second)
34513452
return false;
3452-
3453-
if (UsedInNonLocalBlocksSet.contains(BB))
3454-
return true;
34553453
for (BasicBlock *Succ : successors(BB))
3456-
if (reachesUsed(Succ, UsedInNonLocalBlocksSet, VisitedBlocksSet))
3454+
if (reachesUsed(Succ, ReachesNonLocalUses, VisitedBlocksSet)) {
3455+
ReachesNonLocalUses.insert(BB);
34573456
return true;
3457+
}
34583458
return false;
34593459
}
34603460

@@ -3552,8 +3552,8 @@ foldCondBranchOnValueKnownInPredecessorImpl(BranchInst *BI, DomTreeUpdater *DTU,
35523552
// Check that the block is small enough and record which non-local blocks use
35533553
// values defined in the block.
35543554

3555-
BlocksSet UsedInNonLocalBlocksSet;
3556-
if (!blockIsSimpleEnoughToThreadThrough(BB, UsedInNonLocalBlocksSet))
3555+
BlocksSet ReachesNonLocalUses;
3556+
if (!blockIsSimpleEnoughToThreadThrough(BB, ReachesNonLocalUses))
35573557
return false;
35583558

35593559
for (const auto &Pair : KnownValues) {
@@ -3574,7 +3574,7 @@ foldCondBranchOnValueKnownInPredecessorImpl(BranchInst *BI, DomTreeUpdater *DTU,
35743574

35753575
// Only revector to RealDest if no values defined in BB are live.
35763576
BlocksSet VisitedBlocksSet;
3577-
if (reachesUsed(RealDest, UsedInNonLocalBlocksSet, VisitedBlocksSet))
3577+
if (reachesUsed(RealDest, ReachesNonLocalUses, VisitedBlocksSet))
35783578
continue;
35793579

35803580
LLVM_DEBUG({

0 commit comments

Comments
 (0)