Skip to content

Commit cde58bf

Browse files
[Transforms] Use range constructors of *Set (NFC) (#133203)
1 parent ba1d901 commit cde58bf

15 files changed

+26
-31
lines changed

llvm/lib/Transforms/IPO/ExtractGV.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ static void makeVisible(GlobalValue &GV, bool Delete) {
5252
/// global values specified.
5353
ExtractGVPass::ExtractGVPass(std::vector<GlobalValue *> &GVs, bool deleteS,
5454
bool keepConstInit)
55-
: Named(GVs.begin(), GVs.end()), deleteStuff(deleteS),
55+
: Named(llvm::from_range, GVs), deleteStuff(deleteS),
5656
keepConstInit(keepConstInit) {}
5757

5858
PreservedAnalyses ExtractGVPass::run(Module &M, ModuleAnalysisManager &) {

llvm/lib/Transforms/IPO/GlobalOpt.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2319,10 +2319,10 @@ class LLVMUsed {
23192319
LLVMUsed(Module &M) {
23202320
SmallVector<GlobalValue *, 4> Vec;
23212321
UsedV = collectUsedGlobalVariables(M, Vec, false);
2322-
Used = {Vec.begin(), Vec.end()};
2322+
Used = {llvm::from_range, Vec};
23232323
Vec.clear();
23242324
CompilerUsedV = collectUsedGlobalVariables(M, Vec, true);
2325-
CompilerUsed = {Vec.begin(), Vec.end()};
2325+
CompilerUsed = {llvm::from_range, Vec};
23262326
}
23272327

23282328
using iterator = SmallPtrSet<GlobalValue *, 4>::iterator;

llvm/lib/Transforms/IPO/OpenMPOpt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5874,7 +5874,7 @@ PreservedAnalyses OpenMPOptCGSCCPass::run(LazyCallGraph::SCC &C,
58745874
bool PostLink = LTOPhase == ThinOrFullLTOPhase::FullLTOPostLink ||
58755875
LTOPhase == ThinOrFullLTOPhase::ThinLTOPostLink ||
58765876
LTOPhase == ThinOrFullLTOPhase::ThinLTOPreLink;
5877-
SetVector<Function *> Functions(SCC.begin(), SCC.end());
5877+
SetVector<Function *> Functions(llvm::from_range, SCC);
58785878
OMPInformationCache InfoCache(*(Functions.back()->getParent()), AG, Allocator,
58795879
/*CGSCC*/ &Functions, PostLink);
58805880

llvm/lib/Transforms/Scalar/GVN.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1591,8 +1591,7 @@ bool GVNPass::PerformLoadPRE(LoadInst *Load, AvailValInBlkVect &ValuesPerBlock,
15911591
// that we only have to insert *one* load (which means we're basically moving
15921592
// the load, not inserting a new one).
15931593

1594-
SmallPtrSet<BasicBlock *, 4> Blockers(UnavailableBlocks.begin(),
1595-
UnavailableBlocks.end());
1594+
SmallPtrSet<BasicBlock *, 4> Blockers(llvm::from_range, UnavailableBlocks);
15961595

15971596
// Let's find the first basic block with more than one predecessor. Walk
15981597
// backwards through predecessors if needed.

llvm/lib/Transforms/Scalar/GVNSink.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ class GVNSink {
522522

523523
unsigned NumSunk = 0;
524524
ReversePostOrderTraversal<Function*> RPOT(&F);
525-
VN.setReachableBBs(BasicBlocksSet(RPOT.begin(), RPOT.end()));
525+
VN.setReachableBBs(BasicBlocksSet(llvm::from_range, RPOT));
526526
// Populate reverse post-order to order basic blocks in deterministic
527527
// order. Any arbitrary ordering will work in this case as long as they are
528528
// deterministic. The node ordering of newly created basic blocks

llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -895,7 +895,7 @@ void InferAddressSpacesImpl::inferAddressSpaces(
895895
ArrayRef<WeakTrackingVH> Postorder,
896896
ValueToAddrSpaceMapTy &InferredAddrSpace,
897897
PredicatedAddrSpaceMapTy &PredicatedAS) const {
898-
SetVector<Value *> Worklist(Postorder.begin(), Postorder.end());
898+
SetVector<Value *> Worklist(llvm::from_range, Postorder);
899899
// Initially, all expressions are in the uninitialized address space.
900900
for (Value *V : Postorder)
901901
InferredAddrSpace[V] = UninitializedAddressSpace;

llvm/lib/Transforms/Scalar/LICM.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1564,8 +1564,7 @@ static void splitPredecessorsOfLoopExit(PHINode *PN, DominatorTree *DT,
15641564
#ifndef NDEBUG
15651565
SmallVector<BasicBlock *, 32> ExitBlocks;
15661566
CurLoop->getUniqueExitBlocks(ExitBlocks);
1567-
SmallPtrSet<BasicBlock *, 32> ExitBlockSet(ExitBlocks.begin(),
1568-
ExitBlocks.end());
1567+
SmallPtrSet<BasicBlock *, 32> ExitBlockSet(llvm::from_range, ExitBlocks);
15691568
#endif
15701569
BasicBlock *ExitBB = PN->getParent();
15711570
assert(ExitBlockSet.count(ExitBB) && "Expect the PHI is in an exit block.");
@@ -1699,8 +1698,7 @@ static bool sink(Instruction &I, LoopInfo *LI, DominatorTree *DT,
16991698
#ifndef NDEBUG
17001699
SmallVector<BasicBlock *, 32> ExitBlocks;
17011700
CurLoop->getUniqueExitBlocks(ExitBlocks);
1702-
SmallPtrSet<BasicBlock *, 32> ExitBlockSet(ExitBlocks.begin(),
1703-
ExitBlocks.end());
1701+
SmallPtrSet<BasicBlock *, 32> ExitBlockSet(llvm::from_range, ExitBlocks);
17041702
#endif
17051703

17061704
// Clones of this instruction. Don't create more than one per exit block!

llvm/lib/Transforms/Utils/BasicBlockUtils.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ void llvm::DeleteDeadBlocks(ArrayRef <BasicBlock *> BBs, DomTreeUpdater *DTU,
102102
bool KeepOneInputPHIs) {
103103
#ifndef NDEBUG
104104
// Make sure that all predecessors of each dead block is also dead.
105-
SmallPtrSet<BasicBlock *, 4> Dead(BBs.begin(), BBs.end());
105+
SmallPtrSet<BasicBlock *, 4> Dead(llvm::from_range, BBs);
106106
assert(Dead.size() == BBs.size() && "Duplicating blocks?");
107107
for (auto *BB : Dead)
108108
for (BasicBlock *Pred : predecessors(BB))
@@ -1261,7 +1261,7 @@ static void UpdatePHINodes(BasicBlock *OrigBB, BasicBlock *NewBB,
12611261
ArrayRef<BasicBlock *> Preds, BranchInst *BI,
12621262
bool HasLoopExit) {
12631263
// Otherwise, create a new PHI node in NewBB for each PHI node in OrigBB.
1264-
SmallPtrSet<BasicBlock *, 16> PredSet(Preds.begin(), Preds.end());
1264+
SmallPtrSet<BasicBlock *, 16> PredSet(llvm::from_range, Preds);
12651265
for (BasicBlock::iterator I = OrigBB->begin(); isa<PHINode>(I); ) {
12661266
PHINode *PN = cast<PHINode>(I++);
12671267

llvm/lib/Transforms/Utils/InjectTLIMappings.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,7 @@ static void addMappingsFromTLI(const TargetLibraryInfo &TLI, CallInst &CI) {
8787
SmallVector<std::string, 8> Mappings;
8888
VFABI::getVectorVariantNames(CI, Mappings);
8989
Module *M = CI.getModule();
90-
const SetVector<StringRef> OriginalSetOfMappings(Mappings.begin(),
91-
Mappings.end());
90+
const SetVector<StringRef> OriginalSetOfMappings(llvm::from_range, Mappings);
9291

9392
auto AddVariantDecl = [&](const ElementCount &VF, bool Predicate) {
9493
const VecDesc *VD = TLI.getVectorMappingInfo(ScalarName, VF, Predicate);

llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -815,8 +815,8 @@ void PromoteMem2Reg::run() {
815815
AllocaLookup[Allocas[AllocaNum]] = AllocaNum;
816816

817817
// Unique the set of defining blocks for efficient lookup.
818-
SmallPtrSet<BasicBlock *, 32> DefBlocks(Info.DefiningBlocks.begin(),
819-
Info.DefiningBlocks.end());
818+
SmallPtrSet<BasicBlock *, 32> DefBlocks(llvm::from_range,
819+
Info.DefiningBlocks);
820820

821821
// Determine which blocks the value is live in. These are blocks which lead
822822
// to uses.

llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2389,8 +2389,8 @@ void SCEVExpanderCleaner::cleanup() {
23892389

23902390
auto InsertedInstructions = Expander.getAllInsertedInstructions();
23912391
#ifndef NDEBUG
2392-
SmallPtrSet<Instruction *, 8> InsertedSet(InsertedInstructions.begin(),
2393-
InsertedInstructions.end());
2392+
SmallPtrSet<Instruction *, 8> InsertedSet(llvm::from_range,
2393+
InsertedInstructions);
23942394
(void)InsertedSet;
23952395
#endif
23962396
// Remove sets with value handles.

llvm/lib/Transforms/Utils/SimplifyCFG.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2721,7 +2721,7 @@ bool CompatibleSets::shouldBelongToSameSet(ArrayRef<InvokeInst *> Invokes) {
27212721

27222722
// In the normal destination, the incoming values for these two `invoke`s
27232723
// must be compatible.
2724-
SmallPtrSet<Value *, 16> EquivalenceSet(Invokes.begin(), Invokes.end());
2724+
SmallPtrSet<Value *, 16> EquivalenceSet(llvm::from_range, Invokes);
27252725
if (!incomingValuesAreCompatible(
27262726
NormalBB, {Invokes[0]->getParent(), Invokes[1]->getParent()},
27272727
&EquivalenceSet))

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7325,8 +7325,7 @@ LoopVectorizationPlanner::precomputeCosts(VPlan &Plan, ElementCount VF,
73257325
continue;
73267326

73277327
const auto &ChainOps = RdxDesc.getReductionOpChain(RedPhi, OrigLoop);
7328-
SetVector<Instruction *> ChainOpsAndOperands(ChainOps.begin(),
7329-
ChainOps.end());
7328+
SetVector<Instruction *> ChainOpsAndOperands(llvm::from_range, ChainOps);
73307329
auto IsZExtOrSExt = [](const unsigned Opcode) -> bool {
73317330
return Opcode == Instruction::ZExt || Opcode == Instruction::SExt;
73327331
};

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1821,7 +1821,7 @@ class BoUpSLP {
18211821

18221822
auto CheckSameEntryOrFail = [&]() {
18231823
if (ArrayRef<TreeEntry *> TEs1 = R.getTreeEntries(V1); !TEs1.empty()) {
1824-
SmallPtrSet<TreeEntry *, 4> Set(TEs1.begin(), TEs1.end());
1824+
SmallPtrSet<TreeEntry *, 4> Set(llvm::from_range, TEs1);
18251825
if (ArrayRef<TreeEntry *> TEs2 = R.getTreeEntries(V2);
18261826
!TEs2.empty() &&
18271827
any_of(TEs2, [&](TreeEntry *E) { return Set.contains(E); }))
@@ -8938,7 +8938,7 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth,
89388938
}
89398939
return;
89408940
}
8941-
SmallPtrSet<Value *, 8> Values(E->Scalars.begin(), E->Scalars.end());
8941+
SmallPtrSet<Value *, 8> Values(llvm::from_range, E->Scalars);
89428942
if (all_of(VL, [&](Value *V) {
89438943
return isa<PoisonValue>(V) || Values.contains(V);
89448944
})) {
@@ -9038,8 +9038,8 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth,
90389038
SmallBitVector OpcodeMask(getAltInstrMask(VL, Opcode0, Opcode1));
90399039
// Enable split node, only if all nodes do not form legal alternate
90409040
// instruction (like X86 addsub).
9041-
SmallPtrSet<Value *, 4> UOp1(Op1.begin(), Op1.end());
9042-
SmallPtrSet<Value *, 4> UOp2(Op2.begin(), Op2.end());
9041+
SmallPtrSet<Value *, 4> UOp1(llvm::from_range, Op1);
9042+
SmallPtrSet<Value *, 4> UOp2(llvm::from_range, Op2);
90439043
if (UOp1.size() <= 1 || UOp2.size() <= 1 ||
90449044
TTI.isLegalAltInstr(VecTy, Opcode0, Opcode1, OpcodeMask) ||
90459045
!hasFullVectorsOrPowerOf2(TTI, Op1.front()->getType(), Op1.size()) ||
@@ -14265,7 +14265,7 @@ BoUpSLP::isGatherShuffledSingleRegisterEntry(
1426514265
return std::nullopt;
1426614266
auto *NodeUI = DT->getNode(TEInsertBlock);
1426714267
assert(NodeUI && "Should only process reachable instructions");
14268-
SmallPtrSet<Value *, 4> GatheredScalars(VL.begin(), VL.end());
14268+
SmallPtrSet<Value *, 4> GatheredScalars(llvm::from_range, VL);
1426914269
auto CheckOrdering = [&](const Instruction *InsertPt) {
1427014270
// Argument InsertPt is an instruction where vector code for some other
1427114271
// tree entry (one that shares one or more scalars with TE) is going to be
@@ -21455,7 +21455,7 @@ class HorizontalReduction {
2145521455
}
2145621456
}
2145721457
V.transformNodes();
21458-
SmallPtrSet<Value *, 4> VLScalars(VL.begin(), VL.end());
21458+
SmallPtrSet<Value *, 4> VLScalars(llvm::from_range, VL);
2145921459
// Gather externally used values.
2146021460
SmallPtrSet<Value *, 4> Visited;
2146121461
for (unsigned Cnt = 0; Cnt < NumReducedVals; ++Cnt) {
@@ -23343,7 +23343,7 @@ bool SLPVectorizerPass::vectorizeGEPIndices(BasicBlock *BB, BoUpSLP &R) {
2334323343
// SetVector here to preserve program order. If the index computations
2334423344
// are vectorizable and begin with loads, we want to minimize the chance
2334523345
// of having to reorder them later.
23346-
SetVector<Value *> Candidates(GEPList.begin(), GEPList.end());
23346+
SetVector<Value *> Candidates(llvm::from_range, GEPList);
2334723347

2334823348
// Some of the candidates may have already been vectorized after we
2334923349
// initially collected them or their index is optimized to constant value.

llvm/lib/Transforms/Vectorize/SandboxVectorizer/Legality.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ const LegalityResult &LegalityAnalysis::canVectorize(ArrayRef<Value *> Bndl,
219219
[BB](auto *V) { return cast<Instruction>(V)->getParent() != BB; }))
220220
return createLegalityResult<Pack>(ResultReason::DiffBBs);
221221
// Pack if instructions repeat, i.e., require some sort of broadcast.
222-
SmallPtrSet<Value *, 8> Unique(Bndl.begin(), Bndl.end());
222+
SmallPtrSet<Value *, 8> Unique(llvm::from_range, Bndl);
223223
if (Unique.size() != Bndl.size())
224224
return createLegalityResult<Pack>(ResultReason::RepeatedInstrs);
225225

0 commit comments

Comments
 (0)