Skip to content

Commit 5cfd81b

Browse files
[llvm] Use range constructors of *Set (NFC) (#137552)
1 parent 25b05e0 commit 5cfd81b

14 files changed

+27
-28
lines changed

llvm/lib/Analysis/MemorySSAUpdater.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -679,8 +679,8 @@ void MemorySSAUpdater::updateForClonedLoop(const LoopBlocksRPO &LoopBlocks,
679679
auto FixPhiIncomingValues = [&](MemoryPhi *Phi, MemoryPhi *NewPhi) {
680680
assert(Phi && NewPhi && "Invalid Phi nodes.");
681681
BasicBlock *NewPhiBB = NewPhi->getBlock();
682-
SmallPtrSet<BasicBlock *, 4> NewPhiBBPreds(pred_begin(NewPhiBB),
683-
pred_end(NewPhiBB));
682+
SmallPtrSet<BasicBlock *, 4> NewPhiBBPreds(llvm::from_range,
683+
predecessors(NewPhiBB));
684684
for (unsigned It = 0, E = Phi->getNumIncomingValues(); It < E; ++It) {
685685
MemoryAccess *IncomingAccess = Phi->getIncomingValue(It);
686686
BasicBlock *IncBB = Phi->getIncomingBlock(It);

llvm/lib/CodeGen/MachineBlockPlacement.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,8 +1024,8 @@ bool MachineBlockPlacement::isTrellis(
10241024
if (BB->succ_size() != 2 || ViableSuccs.size() != 2)
10251025
return false;
10261026

1027-
SmallPtrSet<const MachineBasicBlock *, 2> Successors(BB->succ_begin(),
1028-
BB->succ_end());
1027+
SmallPtrSet<const MachineBasicBlock *, 2> Successors(llvm::from_range,
1028+
BB->successors());
10291029
// To avoid reviewing the same predecessors twice.
10301030
SmallPtrSet<const MachineBasicBlock *, 8> SeenPreds;
10311031

@@ -1117,8 +1117,8 @@ MachineBlockPlacement::getBestTrellisSuccessor(
11171117
const BlockFilterSet *BlockFilter) {
11181118

11191119
BlockAndTailDupResult Result = {nullptr, false};
1120-
SmallPtrSet<const MachineBasicBlock *, 4> Successors(BB->succ_begin(),
1121-
BB->succ_end());
1120+
SmallPtrSet<const MachineBasicBlock *, 4> Successors(llvm::from_range,
1121+
BB->successors());
11221122

11231123
// We assume size 2 because it's common. For general n, we would have to do
11241124
// the Hungarian algorithm, but it's not worth the complexity because more
@@ -1209,8 +1209,8 @@ bool MachineBlockPlacement::canTailDuplicateUnplacedPreds(
12091209
unsigned int NumDup = 0;
12101210

12111211
// For CFG checking.
1212-
SmallPtrSet<const MachineBasicBlock *, 4> Successors(BB->succ_begin(),
1213-
BB->succ_end());
1212+
SmallPtrSet<const MachineBasicBlock *, 4> Successors(llvm::from_range,
1213+
BB->successors());
12141214
for (MachineBasicBlock *Pred : Succ->predecessors()) {
12151215
// Make sure all unplaced and unfiltered predecessors can be
12161216
// tail-duplicated into.

llvm/lib/CodeGen/TailDuplicator.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -751,8 +751,8 @@ bool TailDuplicator::canCompletelyDuplicateBB(MachineBasicBlock &BB) {
751751
bool TailDuplicator::duplicateSimpleBB(
752752
MachineBasicBlock *TailBB, SmallVectorImpl<MachineBasicBlock *> &TDBBs,
753753
const DenseSet<Register> &UsedByPhi) {
754-
SmallPtrSet<MachineBasicBlock *, 8> Succs(TailBB->succ_begin(),
755-
TailBB->succ_end());
754+
SmallPtrSet<MachineBasicBlock *, 8> Succs(llvm::from_range,
755+
TailBB->successors());
756756
SmallVector<MachineBasicBlock *, 8> Preds(TailBB->predecessors());
757757
bool Changed = false;
758758
for (MachineBasicBlock *PredBB : Preds) {

llvm/lib/CodeGen/TargetInstrInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1043,7 +1043,7 @@ bool TargetInstrInfo::getAccumulatorReassociationPatterns(
10431043

10441044
// Check if the MBB this instruction is a part of contains any other chains.
10451045
// If so, don't apply it.
1046-
SmallSet<Register, 32> ReductionChain(Chain.begin(), Chain.end());
1046+
SmallSet<Register, 32> ReductionChain(llvm::from_range, Chain);
10471047
for (const auto &I : MBB) {
10481048
if (I.getOpcode() == Opc &&
10491049
!ReductionChain.contains(I.getOperand(0).getReg()))

llvm/lib/CodeGen/UnreachableBlockElim.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,8 @@ bool UnreachableMachineBlockElim::run(MachineFunction &F) {
185185
// Cleanup PHI nodes.
186186
for (MachineBasicBlock &BB : F) {
187187
// Prune unneeded PHI entries.
188-
SmallPtrSet<MachineBasicBlock*, 8> preds(BB.pred_begin(),
189-
BB.pred_end());
188+
SmallPtrSet<MachineBasicBlock *, 8> preds(llvm::from_range,
189+
BB.predecessors());
190190
for (MachineInstr &Phi : make_early_inc_range(BB.phis())) {
191191
for (unsigned i = Phi.getNumOperands() - 1; i >= 2; i -= 2) {
192192
if (!preds.count(Phi.getOperand(i).getMBB())) {

llvm/lib/Target/Hexagon/HexagonExpandCondsets.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ void HexagonExpandCondsets::updateDeadsInRange(Register Reg, LaneBitmask LM,
382382
return true;
383383
}
384384
MachineBasicBlock *Entry = &Dest->getParent()->front();
385-
SetVector<MachineBasicBlock*> Work(Dest->pred_begin(), Dest->pred_end());
385+
SetVector<MachineBasicBlock *> Work(llvm::from_range, Dest->predecessors());
386386
for (unsigned i = 0; i < Work.size(); ++i) {
387387
MachineBasicBlock *B = Work[i];
388388
if (Defs.count(B))

llvm/lib/Transforms/Scalar/ADCE.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -485,10 +485,8 @@ void AggressiveDeadCodeElimination::markLiveBranchesFromControlDependences() {
485485
// which currently have dead terminators that are control
486486
// dependence sources of a block which is in NewLiveBlocks.
487487

488-
const SmallPtrSet<BasicBlock *, 16> BWDT{
489-
BlocksWithDeadTerminators.begin(),
490-
BlocksWithDeadTerminators.end()
491-
};
488+
const SmallPtrSet<BasicBlock *, 16> BWDT(llvm::from_range,
489+
BlocksWithDeadTerminators);
492490
SmallVector<BasicBlock *, 32> IDFBlocks;
493491
ReverseIDFCalculator IDFs(PDT);
494492
IDFs.setDefiningBlocks(NewLiveBlocks);

llvm/lib/Transforms/Utils/BasicBlockUtils.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,8 @@ bool llvm::MergeBlockIntoPredecessor(BasicBlock *BB, DomTreeUpdater *DTU,
249249
assert(!DT && "cannot use both DT and DTU for updates");
250250
// To avoid processing the same predecessor more than once.
251251
SmallPtrSet<BasicBlock *, 8> SeenSuccs;
252-
SmallPtrSet<BasicBlock *, 2> SuccsOfPredBB(succ_begin(PredBB),
253-
succ_end(PredBB));
252+
SmallPtrSet<BasicBlock *, 2> SuccsOfPredBB(llvm::from_range,
253+
successors(PredBB));
254254
Updates.reserve(Updates.size() + 2 * succ_size(BB) + 1);
255255
// Add insert edges first. Experimentally, for the particular case of two
256256
// blocks that can be merged, with a single successor and single predecessor

llvm/lib/Transforms/Utils/FlattenCFG.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ bool FlattenCFGOpt::FlattenParallelAndOr(BasicBlock *BB, IRBuilder<> &Builder) {
144144
int Idx = -1;
145145

146146
// Check predecessors of \param BB.
147-
SmallPtrSet<BasicBlock *, 16> Preds(pred_begin(BB), pred_end(BB));
147+
SmallPtrSet<BasicBlock *, 16> Preds(llvm::from_range, predecessors(BB));
148148
for (BasicBlock *Pred : Preds) {
149149
BranchInst *PBI = dyn_cast<BranchInst>(Pred->getTerminator());
150150

llvm/lib/Transforms/Utils/Local.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,7 +1158,7 @@ bool llvm::TryToSimplifyUncondBranchFromEmptyBlock(BasicBlock *BB,
11581158
if (BB == Succ)
11591159
return false;
11601160

1161-
SmallPtrSet<BasicBlock *, 16> BBPreds(pred_begin(BB), pred_end(BB));
1161+
SmallPtrSet<BasicBlock *, 16> BBPreds(llvm::from_range, predecessors(BB));
11621162

11631163
// The single common predecessor of BB and Succ when BB cannot be killed
11641164
BasicBlock *CommonPred = nullptr;
@@ -1293,7 +1293,8 @@ bool llvm::TryToSimplifyUncondBranchFromEmptyBlock(BasicBlock *BB,
12931293
// All predecessors of BB (except the common predecessor) will be moved to
12941294
// Succ.
12951295
Updates.reserve(Updates.size() + 2 * pred_size(BB) + 1);
1296-
SmallPtrSet<BasicBlock *, 16> SuccPreds(pred_begin(Succ), pred_end(Succ));
1296+
SmallPtrSet<BasicBlock *, 16> SuccPreds(llvm::from_range,
1297+
predecessors(Succ));
12971298
for (auto *PredOfBB : predecessors(BB)) {
12981299
// Do not modify those common predecessors of BB and Succ
12991300
if (!SuccPreds.contains(PredOfBB))

llvm/lib/Transforms/Utils/SimplifyCFG.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ safeToMergeTerminators(Instruction *SI1, Instruction *SI2,
367367
BasicBlock *SI1BB = SI1->getParent();
368368
BasicBlock *SI2BB = SI2->getParent();
369369

370-
SmallPtrSet<BasicBlock *, 16> SI1Succs(succ_begin(SI1BB), succ_end(SI1BB));
370+
SmallPtrSet<BasicBlock *, 16> SI1Succs(llvm::from_range, successors(SI1BB));
371371
bool Fail = false;
372372
for (BasicBlock *Succ : successors(SI2BB)) {
373373
if (!SI1Succs.count(Succ))
@@ -1332,7 +1332,7 @@ bool SimplifyCFGOpt::performValueComparisonIntoPredecessorFolding(
13321332
// successors.
13331333
SmallPtrSet<BasicBlock *, 2> SuccsOfPred;
13341334
if (DTU) {
1335-
SuccsOfPred = {succ_begin(Pred), succ_end(Pred)};
1335+
SuccsOfPred = {llvm::from_range, successors(Pred)};
13361336
Updates.reserve(Updates.size() + NewSuccessors.size());
13371337
}
13381338
for (const std::pair<BasicBlock *, int /*Num*/> &NewSuccessor :

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8425,7 +8425,7 @@ void VPRecipeBuilder::createBlockInMask(BasicBlock *BB) {
84258425
VPValue *BlockMask = nullptr;
84268426
// This is the block mask. We OR all unique incoming edges.
84278427
for (auto *Predecessor :
8428-
SetVector<BasicBlock *>(pred_begin(BB), pred_end(BB))) {
8428+
SetVector<BasicBlock *>(llvm::from_range, predecessors(BB))) {
84298429
VPValue *EdgeMask = createEdgeMask(Predecessor, BB);
84308430
if (!EdgeMask) { // Mask of predecessor is all-one so mask of block is too.
84318431
BlockMaskCache[BB] = EdgeMask;

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10107,7 +10107,7 @@ void BoUpSLP::buildTreeRec(ArrayRef<Value *> VL, unsigned Depth,
1010710107

1010810108
BlockScheduling &BS = *BSRef;
1010910109

10110-
SetVector<Value *> UniqueValues(VL.begin(), VL.end());
10110+
SetVector<Value *> UniqueValues(llvm::from_range, VL);
1011110111
std::optional<ScheduleBundle *> BundlePtr =
1011210112
BS.tryScheduleBundle(UniqueValues.getArrayRef(), this, S);
1011310113
#ifdef EXPENSIVE_CHECKS

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ createScalarIVSteps(VPlan &Plan, InductionDescriptor::InductionKind Kind,
597597
}
598598

599599
static SmallVector<VPUser *> collectUsersRecursively(VPValue *V) {
600-
SetVector<VPUser *> Users(V->user_begin(), V->user_end());
600+
SetVector<VPUser *> Users(llvm::from_range, V->users());
601601
for (unsigned I = 0; I != Users.size(); ++I) {
602602
VPRecipeBase *Cur = cast<VPRecipeBase>(Users[I]);
603603
if (isa<VPHeaderPHIRecipe>(Cur))

0 commit comments

Comments
 (0)