Skip to content

Commit 20b9189

Browse files
author
Max Kazantsev
committed
[NFC] Rename DontDeleteUselessPHIs --> KeepOneInputPHIs
llvm-svn: 353801
1 parent b6dc6eb commit 20b9189

File tree

9 files changed

+29
-29
lines changed

9 files changed

+29
-29
lines changed

llvm/include/llvm/IR/BasicBlock.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ class BasicBlock final : public Value, // Basic blocks are data objects also
362362
/// This is actually not used to update the Predecessor list, but is actually
363363
/// used to update the PHI nodes that reside in the block. Note that this
364364
/// should be called while the predecessor still refers to this block.
365-
void removePredecessor(BasicBlock *Pred, bool DontDeleteUselessPHIs = false);
365+
void removePredecessor(BasicBlock *Pred, bool KeepOneInputPHIs = false);
366366

367367
bool canSplitPredecessors() const;
368368

llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h

+8-8
Original file line numberDiff line numberDiff line change
@@ -41,25 +41,25 @@ class Value;
4141

4242
/// Replace contents of every block in \p BBs with single unreachable
4343
/// instruction. If \p Updates is specified, collect all necessary DT updates
44-
/// into this vector. If \p DontDeleteUselessPHIs is true, one-input Phis in
44+
/// into this vector. If \p KeepOneInputPHIs is true, one-input Phis in
4545
/// successors of blocks being deleted will be preserved.
4646
void DetatchDeadBlocks(ArrayRef <BasicBlock *> BBs,
4747
SmallVectorImpl<DominatorTree::UpdateType> *Updates,
48-
bool DontDeleteUselessPHIs = false);
48+
bool KeepOneInputPHIs = false);
4949

5050
/// Delete the specified block, which must have no predecessors.
5151
void DeleteDeadBlock(BasicBlock *BB, DomTreeUpdater *DTU = nullptr,
52-
bool DontDeleteUselessPHIs = false);
52+
bool KeepOneInputPHIs = false);
5353

5454
/// Delete the specified blocks from \p BB. The set of deleted blocks must have
5555
/// no predecessors that are not being deleted themselves. \p BBs must have no
5656
/// duplicating blocks. If there are loops among this set of blocks, all
5757
/// relevant loop info updates should be done before this function is called.
58-
/// If \p DontDeleteUselessPHIs is true, one-input Phis in successors of blocks
58+
/// If \p KeepOneInputPHIs is true, one-input Phis in successors of blocks
5959
/// being deleted will be preserved.
6060
void DeleteDeadBlocks(ArrayRef <BasicBlock *> BBs,
6161
DomTreeUpdater *DTU = nullptr,
62-
bool DontDeleteUselessPHIs = false);
62+
bool KeepOneInputPHIs = false);
6363

6464
/// We know that BB has one predecessor. If there are any single-entry PHI nodes
6565
/// in it, fold them away. This handles the case when all entries to the PHI
@@ -106,7 +106,7 @@ struct CriticalEdgeSplittingOptions {
106106
LoopInfo *LI;
107107
MemorySSAUpdater *MSSAU;
108108
bool MergeIdenticalEdges = false;
109-
bool DontDeleteUselessPHIs = false;
109+
bool KeepOneInputPHIs = false;
110110
bool PreserveLCSSA = false;
111111

112112
CriticalEdgeSplittingOptions(DominatorTree *DT = nullptr,
@@ -119,8 +119,8 @@ struct CriticalEdgeSplittingOptions {
119119
return *this;
120120
}
121121

122-
CriticalEdgeSplittingOptions &setDontDeleteUselessPHIs() {
123-
DontDeleteUselessPHIs = true;
122+
CriticalEdgeSplittingOptions &setKeepOneInputPHIs() {
123+
KeepOneInputPHIs = true;
124124
return *this;
125125
}
126126

llvm/lib/IR/BasicBlock.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ iterator_range<BasicBlock::phi_iterator> BasicBlock::phis() {
299299
/// called while the predecessor still refers to this block.
300300
///
301301
void BasicBlock::removePredecessor(BasicBlock *Pred,
302-
bool DontDeleteUselessPHIs) {
302+
bool KeepOneInputPHIs) {
303303
assert((hasNUsesOrMore(16)||// Reduce cost of this assertion for complex CFGs.
304304
find(pred_begin(this), pred_end(this), Pred) != pred_end(this)) &&
305305
"removePredecessor: BB is not a predecessor!");
@@ -330,11 +330,11 @@ void BasicBlock::removePredecessor(BasicBlock *Pred,
330330
}
331331

332332
// <= Two predecessors BEFORE I remove one?
333-
if (max_idx <= 2 && !DontDeleteUselessPHIs) {
333+
if (max_idx <= 2 && !KeepOneInputPHIs) {
334334
// Yup, loop through and nuke the PHI nodes
335335
while (PHINode *PN = dyn_cast<PHINode>(&front())) {
336336
// Remove the predecessor first.
337-
PN->removeIncomingValue(Pred, !DontDeleteUselessPHIs);
337+
PN->removeIncomingValue(Pred, !KeepOneInputPHIs);
338338

339339
// If the PHI _HAD_ two uses, replace PHI node with its now *single* value
340340
if (max_idx == 2) {
@@ -359,7 +359,7 @@ void BasicBlock::removePredecessor(BasicBlock *Pred,
359359
// If all incoming values to the Phi are the same, we can replace the Phi
360360
// with that value.
361361
Value* PNV = nullptr;
362-
if (!DontDeleteUselessPHIs && (PNV = PN->hasConstantValue()))
362+
if (!KeepOneInputPHIs && (PNV = PN->hasConstantValue()))
363363
if (PNV != PN) {
364364
PN->replaceAllUsesWith(PNV);
365365
PN->eraseFromParent();

llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -5292,7 +5292,7 @@ void LSRInstance::RewriteForPHI(
52925292
NewBB = SplitCriticalEdge(BB, Parent,
52935293
CriticalEdgeSplittingOptions(&DT, &LI)
52945294
.setMergeIdenticalEdges()
5295-
.setDontDeleteUselessPHIs());
5295+
.setKeepOneInputPHIs());
52965296
} else {
52975297
SmallVector<BasicBlock*, 2> NewBBs;
52985298
SplitLandingPadPredecessors(Parent, BB, "", "", NewBBs, &DT, &LI);

llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,7 @@ static bool unswitchTrivialSwitch(Loop &L, SwitchInst &SI, DominatorTree &DT,
761761
continue;
762762
}
763763
CommonSuccBB->removePredecessor(BB,
764-
/*DontDeleteUselessPHIs*/ true);
764+
/*KeepOneInputPHIs*/ true);
765765
}
766766
// Now nuke the switch and replace it with a direct branch.
767767
SI.eraseFromParent();
@@ -1069,7 +1069,7 @@ static BasicBlock *buildClonedLoopBlocks(
10691069
continue;
10701070

10711071
ClonedSuccBB->removePredecessor(ClonedParentBB,
1072-
/*DontDeleteUselessPHIs*/ true);
1072+
/*KeepOneInputPHIs*/ true);
10731073
}
10741074

10751075
// Replace the cloned branch with an unconditional branch to the cloned
@@ -2078,7 +2078,7 @@ static void unswitchNontrivialInvariants(
20782078
"Only one possible unswitched block for a branch!");
20792079
BasicBlock *UnswitchedSuccBB = *UnswitchedSuccBBs.begin();
20802080
UnswitchedSuccBB->removePredecessor(ParentBB,
2081-
/*DontDeleteUselessPHIs*/ true);
2081+
/*KeepOneInputPHIs*/ true);
20822082
DTUpdates.push_back({DominatorTree::Delete, ParentBB, UnswitchedSuccBB});
20832083
} else {
20842084
// Note that we actually want to remove the parent block as a predecessor
@@ -2093,7 +2093,7 @@ static void unswitchNontrivialInvariants(
20932093
for (auto &Case : NewSI->cases())
20942094
Case.getCaseSuccessor()->removePredecessor(
20952095
ParentBB,
2096-
/*DontDeleteUselessPHIs*/ true);
2096+
/*KeepOneInputPHIs*/ true);
20972097

20982098
// We need to use the set to populate domtree updates as even when there
20992099
// are multiple cases pointing at the same successor we only want to

llvm/lib/Transforms/Utils/BasicBlockUtils.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ using namespace llvm;
5050
void llvm::DetatchDeadBlocks(
5151
ArrayRef<BasicBlock *> BBs,
5252
SmallVectorImpl<DominatorTree::UpdateType> *Updates,
53-
bool DontDeleteUselessPHIs) {
53+
bool KeepOneInputPHIs) {
5454
for (auto *BB : BBs) {
5555
// Loop through all of our successors and make sure they know that one
5656
// of their predecessors is going away.
5757
SmallPtrSet<BasicBlock *, 4> UniqueSuccessors;
5858
for (BasicBlock *Succ : successors(BB)) {
59-
Succ->removePredecessor(BB, DontDeleteUselessPHIs);
59+
Succ->removePredecessor(BB, KeepOneInputPHIs);
6060
if (Updates && UniqueSuccessors.insert(Succ).second)
6161
Updates->push_back({DominatorTree::Delete, BB, Succ});
6262
}
@@ -82,12 +82,12 @@ void llvm::DetatchDeadBlocks(
8282
}
8383

8484
void llvm::DeleteDeadBlock(BasicBlock *BB, DomTreeUpdater *DTU,
85-
bool DontDeleteUselessPHIs) {
86-
DeleteDeadBlocks({BB}, DTU, DontDeleteUselessPHIs);
85+
bool KeepOneInputPHIs) {
86+
DeleteDeadBlocks({BB}, DTU, KeepOneInputPHIs);
8787
}
8888

8989
void llvm::DeleteDeadBlocks(ArrayRef <BasicBlock *> BBs, DomTreeUpdater *DTU,
90-
bool DontDeleteUselessPHIs) {
90+
bool KeepOneInputPHIs) {
9191
#ifndef NDEBUG
9292
// Make sure that all predecessors of each dead block is also dead.
9393
SmallPtrSet<BasicBlock *, 4> Dead(BBs.begin(), BBs.end());
@@ -98,7 +98,7 @@ void llvm::DeleteDeadBlocks(ArrayRef <BasicBlock *> BBs, DomTreeUpdater *DTU,
9898
#endif
9999

100100
SmallVector<DominatorTree::UpdateType, 4> Updates;
101-
DetatchDeadBlocks(BBs, DTU ? &Updates : nullptr, DontDeleteUselessPHIs);
101+
DetatchDeadBlocks(BBs, DTU ? &Updates : nullptr, KeepOneInputPHIs);
102102

103103
if (DTU)
104104
DTU->applyUpdates(Updates, /*ForceRemoveDuplicates*/ true);

llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ llvm::SplitCriticalEdge(Instruction *TI, unsigned SuccNum,
192192
if (TI->getSuccessor(i) != DestBB) continue;
193193

194194
// Remove an entry for TIBB from DestBB phi nodes.
195-
DestBB->removePredecessor(TIBB, Options.DontDeleteUselessPHIs);
195+
DestBB->removePredecessor(TIBB, Options.KeepOneInputPHIs);
196196

197197
// We found another edge to DestBB, go to NewBB instead.
198198
TI->setSuccessor(i, NewBB);

llvm/lib/Transforms/Utils/LoopSimplify.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -662,9 +662,9 @@ static bool simplifyOneLoop(Loop *L, SmallVectorImpl<Loop *> &Worklist,
662662
DT->eraseNode(ExitingBlock);
663663

664664
BI->getSuccessor(0)->removePredecessor(
665-
ExitingBlock, /* DontDeleteUselessPHIs */ PreserveLCSSA);
665+
ExitingBlock, /* KeepOneInputPHIs */ PreserveLCSSA);
666666
BI->getSuccessor(1)->removePredecessor(
667-
ExitingBlock, /* DontDeleteUselessPHIs */ PreserveLCSSA);
667+
ExitingBlock, /* KeepOneInputPHIs */ PreserveLCSSA);
668668
ExitingBlock->eraseFromParent();
669669
}
670670
}

llvm/lib/Transforms/Utils/SimplifyCFG.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -3436,7 +3436,7 @@ static bool SimplifyTerminatorOnSelect(Instruction *OldTerm, Value *Cond,
34363436
KeepEdge2 = nullptr;
34373437
else
34383438
Succ->removePredecessor(OldTerm->getParent(),
3439-
/*DontDeleteUselessPHIs=*/true);
3439+
/*KeepOneInputPHIs=*/true);
34403440
}
34413441

34423442
IRBuilder<> Builder(OldTerm);
@@ -5433,7 +5433,7 @@ static bool SwitchToLookupTable(SwitchInst *SI, IRBuilder<> &Builder,
54335433
// We cached PHINodes in PHIs. To avoid accessing deleted PHINodes later,
54345434
// do not delete PHINodes here.
54355435
SI->getDefaultDest()->removePredecessor(SI->getParent(),
5436-
/*DontDeleteUselessPHIs=*/true);
5436+
/*KeepOneInputPHIs=*/true);
54375437
}
54385438

54395439
bool ReturnedEarly = false;

0 commit comments

Comments
 (0)