Skip to content

Commit 7a4c521

Browse files
committed
Don't unnecessarily cache.
1 parent 03d9ec6 commit 7a4c521

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

llvm/lib/Transforms/Utils/Local.cpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,11 +1020,9 @@ static void replaceUndefValuesInPhi(PHINode *PN,
10201020
// Only when they shares a single common predecessor, return true.
10211021
// Only handles cases when BB can't be merged while its predecessors can be
10221022
// redirected.
1023-
// \p SuccPredsOut may be partially populated with the predecessors of Succ.
10241023
static bool
10251024
CanRedirectPredsOfEmptyBBToSucc(BasicBlock *BB, BasicBlock *Succ,
10261025
const SmallPtrSetImpl<BasicBlock *> &BBPreds,
1027-
SmallPtrSetImpl<BasicBlock *> &SuccPredsOut,
10281026
BasicBlock *&CommonPred) {
10291027

10301028
// There must be phis in BB, otherwise BB will be merged into Succ directly
@@ -1044,7 +1042,6 @@ CanRedirectPredsOfEmptyBBToSucc(BasicBlock *BB, BasicBlock *Succ,
10441042
// Get the single common predecessor of both BB and Succ. Return false
10451043
// when there are more than one common predecessors.
10461044
for (BasicBlock *SuccPred : predecessors(Succ)) {
1047-
SuccPredsOut.insert(SuccPred);
10481045
if (BBPreds.count(SuccPred)) {
10491046
if (CommonPred)
10501047
return false;
@@ -1168,7 +1165,6 @@ bool llvm::TryToSimplifyUncondBranchFromEmptyBlock(BasicBlock *BB,
11681165
return false;
11691166

11701167
SmallPtrSet<BasicBlock *, 16> BBPreds(pred_begin(BB), pred_end(BB));
1171-
SmallPtrSet<BasicBlock *, 16> SuccPreds;
11721168

11731169
// The single common predecessor of BB and Succ when BB cannot be killed
11741170
BasicBlock *CommonPred = nullptr;
@@ -1177,16 +1173,13 @@ bool llvm::TryToSimplifyUncondBranchFromEmptyBlock(BasicBlock *BB,
11771173

11781174
// Even if we can not fold BB into Succ, we may be able to redirect the
11791175
// predecessors of BB to Succ.
1180-
bool BBPhisMergeable =
1181-
BBKillable ||
1182-
CanRedirectPredsOfEmptyBBToSucc(BB, Succ, BBPreds, SuccPreds, CommonPred);
1176+
bool BBPhisMergeable = BBKillable || CanRedirectPredsOfEmptyBBToSucc(
1177+
BB, Succ, BBPreds, CommonPred);
11831178

11841179
if ((!BBKillable && !BBPhisMergeable) || introduceTooManyPhiEntries(BB, Succ))
11851180
return false;
11861181

1187-
// SuccPreds may not have been fully filled by CanRedirectPredsOfEmptyBBToSucc
1188-
// so finish it here.
1189-
SuccPreds.insert(pred_begin(Succ), pred_end(Succ));
1182+
SmallPtrSet<BasicBlock *, 16> SuccPreds(pred_begin(Succ), pred_end(Succ));
11901183

11911184
// Check to see if merging these blocks/phis would cause conflicts for any of
11921185
// the phi nodes in BB or Succ. If not, we can safely merge.

0 commit comments

Comments
 (0)