diff --git a/llvm/include/llvm/Support/GenericDomTreeConstruction.h b/llvm/include/llvm/Support/GenericDomTreeConstruction.h index 5c3c54c552398..557c9ec319e33 100644 --- a/llvm/include/llvm/Support/GenericDomTreeConstruction.h +++ b/llvm/include/llvm/Support/GenericDomTreeConstruction.h @@ -697,7 +697,7 @@ struct SemiNCAInfo { const SmallVectorImpl &B) { if (A.size() != B.size()) return false; - SmallPtrSet Set(A.begin(), A.end()); + SmallPtrSet Set(llvm::from_range, A); for (NodePtr N : B) if (Set.count(N) == 0) return false; diff --git a/llvm/include/llvm/Transforms/Utils/FunctionImportUtils.h b/llvm/include/llvm/Transforms/Utils/FunctionImportUtils.h index 18cd923d5601d..6d83b615d5f13 100644 --- a/llvm/include/llvm/Transforms/Utils/FunctionImportUtils.h +++ b/llvm/include/llvm/Transforms/Utils/FunctionImportUtils.h @@ -116,7 +116,7 @@ class FunctionImportGlobalProcessing { collectUsedGlobalVariables(M, Vec, /*CompilerUsed=*/false); // Next collect those in the llvm.compiler.used set. collectUsedGlobalVariables(M, Vec, /*CompilerUsed=*/true); - Used = {Vec.begin(), Vec.end()}; + Used = {llvm::from_range, Vec}; #endif } diff --git a/llvm/lib/Analysis/DependenceGraphBuilder.cpp b/llvm/lib/Analysis/DependenceGraphBuilder.cpp index 5664e2f27a61a..7180074d03425 100644 --- a/llvm/lib/Analysis/DependenceGraphBuilder.cpp +++ b/llvm/lib/Analysis/DependenceGraphBuilder.cpp @@ -131,7 +131,7 @@ template void AbstractDependenceGraphBuilder::createPiBlocks() { // Build a set to speed up the lookup for edges whose targets // are inside the SCC. - SmallPtrSet NodesInSCC(NL.begin(), NL.end()); + SmallPtrSet NodesInSCC(llvm::from_range, NL); // We have the set of nodes in the SCC. We go through the set of nodes // that are outside of the SCC and look for edges that cross the two sets. diff --git a/llvm/lib/Analysis/LazyCallGraph.cpp b/llvm/lib/Analysis/LazyCallGraph.cpp index 5aa36bfc36d46..d45ce2a3ac66c 100644 --- a/llvm/lib/Analysis/LazyCallGraph.cpp +++ b/llvm/lib/Analysis/LazyCallGraph.cpp @@ -1084,7 +1084,7 @@ LazyCallGraph::RefSCC::insertIncomingRefEdge(Node &SourceN, Node &TargetN) { // Build a set, so we can do fast tests for whether a RefSCC will end up as // part of the merged RefSCC. - SmallPtrSet MergeSet(MergeRange.begin(), MergeRange.end()); + SmallPtrSet MergeSet(llvm::from_range, MergeRange); // This RefSCC will always be part of that set, so just insert it here. MergeSet.insert(this); diff --git a/llvm/lib/Analysis/MemorySSAUpdater.cpp b/llvm/lib/Analysis/MemorySSAUpdater.cpp index 7c6b58cebfd87..5e4477ee43f27 100644 --- a/llvm/lib/Analysis/MemorySSAUpdater.cpp +++ b/llvm/lib/Analysis/MemorySSAUpdater.cpp @@ -1083,8 +1083,8 @@ void MemorySSAUpdater::applyInsertUpdates(ArrayRef Updates, SmallVector IDFBlocks; if (!BlocksToProcess.empty()) { ForwardIDFCalculator IDFs(DT, GD); - SmallPtrSet DefiningBlocks(BlocksToProcess.begin(), - BlocksToProcess.end()); + SmallPtrSet DefiningBlocks(llvm::from_range, + BlocksToProcess); IDFs.setDefiningBlocks(DefiningBlocks); IDFs.calculate(IDFBlocks); @@ -1265,7 +1265,7 @@ void MemorySSAUpdater::wireOldPredecessorsToNewImmediatePredecessor( assert(!Preds.empty() && "Must be moving at least one predecessor to the " "new immediate predecessor."); MemoryPhi *NewPhi = MSSA->createMemoryPhi(New); - SmallPtrSet PredsSet(Preds.begin(), Preds.end()); + SmallPtrSet PredsSet(llvm::from_range, Preds); // Currently only support the case of removing a single incoming edge when // identical edges were not merged. if (!IdenticalEdgesWereMerged) diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index 314baa7c7aee1..600a061d4435e 100644 --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -14217,7 +14217,7 @@ void ScalarEvolution::forgetBackedgeTakenCounts(const Loop *L, } void ScalarEvolution::forgetMemoizedResults(ArrayRef SCEVs) { - SmallPtrSet ToForget(SCEVs.begin(), SCEVs.end()); + SmallPtrSet ToForget(llvm::from_range, SCEVs); SmallVector Worklist(ToForget.begin(), ToForget.end()); while (!Worklist.empty()) { diff --git a/llvm/lib/CodeGen/RDFGraph.cpp b/llvm/lib/CodeGen/RDFGraph.cpp index 6d836af3ffc5c..bbd3292fd46de 100644 --- a/llvm/lib/CodeGen/RDFGraph.cpp +++ b/llvm/lib/CodeGen/RDFGraph.cpp @@ -1415,7 +1415,7 @@ void DataFlowGraph::recordDefsForDF(BlockRefsMap &PhiM, // Calculate the iterated dominance frontier of BB. const MachineDominanceFrontier::DomSetType &DF = DFLoc->second; - SetVector IDF(DF.begin(), DF.end()); + SetVector IDF(llvm::from_range, DF); for (unsigned i = 0; i < IDF.size(); ++i) { auto F = MDF.find(IDF[i]); if (F != MDF.end()) diff --git a/llvm/lib/CodeGen/RDFLiveness.cpp b/llvm/lib/CodeGen/RDFLiveness.cpp index 3502e4bb393c8..b0f0f2501515a 100644 --- a/llvm/lib/CodeGen/RDFLiveness.cpp +++ b/llvm/lib/CodeGen/RDFLiveness.cpp @@ -759,7 +759,7 @@ void Liveness::computeLiveIns() { auto F1 = MDF.find(&B); if (F1 == MDF.end()) continue; - SetVector IDFB(F1->second.begin(), F1->second.end()); + SetVector IDFB(llvm::from_range, F1->second); for (unsigned i = 0; i < IDFB.size(); ++i) { auto F2 = MDF.find(IDFB[i]); if (F2 != MDF.end()) diff --git a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp index 2e5ce5308eea5..cb2376f59e32e 100644 --- a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp +++ b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp @@ -4864,7 +4864,7 @@ static void redirectAllPredecessorsTo(BasicBlock *OldTarget, /// Determine which blocks in \p BBs are reachable from outside and remove the /// ones that are not reachable from the function. static void removeUnusedBlocksFromParent(ArrayRef BBs) { - SmallPtrSet BBsToErase{BBs.begin(), BBs.end()}; + SmallPtrSet BBsToErase(llvm::from_range, BBs); auto HasRemainingUses = [&BBsToErase](BasicBlock *BB) { for (Use &U : BB->uses()) { auto *UseInst = dyn_cast(U.getUser()); diff --git a/llvm/lib/IR/DIBuilder.cpp b/llvm/lib/IR/DIBuilder.cpp index 9e7aea882c593..3c1fd433fb948 100644 --- a/llvm/lib/IR/DIBuilder.cpp +++ b/llvm/lib/IR/DIBuilder.cpp @@ -38,7 +38,7 @@ DIBuilder::DIBuilder(Module &m, bool AllowUnresolvedNodes, DICompileUnit *CU) if (const auto &IMs = CUNode->getImportedEntities()) ImportedModules.assign(IMs.begin(), IMs.end()); if (const auto &MNs = CUNode->getMacros()) - AllMacrosPerParent.insert({nullptr, {MNs.begin(), MNs.end()}}); + AllMacrosPerParent.insert({nullptr, {llvm::from_range, MNs}}); } } diff --git a/llvm/lib/IR/VFABIDemangler.cpp b/llvm/lib/IR/VFABIDemangler.cpp index 62f96b10cea4a..2de05a5432636 100644 --- a/llvm/lib/IR/VFABIDemangler.cpp +++ b/llvm/lib/IR/VFABIDemangler.cpp @@ -541,7 +541,7 @@ void VFABI::getVectorVariantNames( SmallVector ListAttr; S.split(ListAttr, ","); - for (const auto &S : SetVector(ListAttr.begin(), ListAttr.end())) { + for (const auto &S : SetVector(llvm::from_range, ListAttr)) { std::optional Info = VFABI::tryDemangleForVFABI(S, CI.getFunctionType()); if (Info && CI.getModule()->getFunction(Info->VectorName)) { diff --git a/llvm/lib/Object/IRSymtab.cpp b/llvm/lib/Object/IRSymtab.cpp index 2e818be334a5e..806477ae3de01 100644 --- a/llvm/lib/Object/IRSymtab.cpp +++ b/llvm/lib/Object/IRSymtab.cpp @@ -140,7 +140,7 @@ Error Builder::addModule(Module *M) { SmallVector UsedV; collectUsedGlobalVariables(*M, UsedV, /*CompilerUsed=*/false); collectUsedGlobalVariables(*M, UsedV, /*CompilerUsed=*/true); - SmallPtrSet Used(UsedV.begin(), UsedV.end()); + SmallPtrSet Used(llvm::from_range, UsedV); ModuleSymbolTable Msymtab; Msymtab.addModule(M); diff --git a/llvm/lib/Target/AMDGPU/AMDGPUSwLowerLDS.cpp b/llvm/lib/Target/AMDGPU/AMDGPUSwLowerLDS.cpp index 2a41f7cad1f00..f9facfa461748 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPUSwLowerLDS.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPUSwLowerLDS.cpp @@ -227,7 +227,7 @@ template SetVector sortByName(std::vector &&V) { sort(V, [](const auto *L, const auto *R) { return L->getName() < R->getName(); }); - return {SetVector(V.begin(), V.end())}; + return {SetVector(llvm::from_range, V)}; } SetVector AMDGPUSwLowerLDS::getOrderedNonKernelAllLDSGlobals( diff --git a/llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp b/llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp index 666173b87f9da..f77fabf81a29d 100644 --- a/llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp +++ b/llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp @@ -1331,7 +1331,7 @@ bool PolynomialMultiplyRecognize::convertShiftsToLeft(BasicBlock *LoopB, // Find the set of all values affected by the shift cycles, i.e. all // cycled values, and (recursively) all their users. - ValueSeq Users(Cycled.begin(), Cycled.end()); + ValueSeq Users(llvm::from_range, Cycled); for (unsigned i = 0; i < Users.size(); ++i) { Value *V = Users[i]; if (!isa(V->getType())) @@ -1359,7 +1359,7 @@ bool PolynomialMultiplyRecognize::convertShiftsToLeft(BasicBlock *LoopB, return false; // Verify that high bits remain zero. - ValueSeq Internal(Users.begin(), Users.end()); + ValueSeq Internal(llvm::from_range, Users); ValueSeq Inputs; for (unsigned i = 0; i < Internal.size(); ++i) { auto *R = dyn_cast(Internal[i]); @@ -2305,7 +2305,7 @@ bool HexagonLoopIdiomRecognize::coverLoop(Loop *L, SmallSet LoopBlocks; LoopBlocks.insert_range(L->blocks()); - SetVector Worklist(Insts.begin(), Insts.end()); + SetVector Worklist(llvm::from_range, Insts); // Collect all instructions from the loop that the instructions in Insts // depend on (plus their dependencies, etc.). These instructions will diff --git a/llvm/tools/llvm-extract/llvm-extract.cpp b/llvm/tools/llvm-extract/llvm-extract.cpp index 9641178c78069..169cd0c2e4cbf 100644 --- a/llvm/tools/llvm-extract/llvm-extract.cpp +++ b/llvm/tools/llvm-extract/llvm-extract.cpp @@ -313,7 +313,7 @@ int main(int argc, char **argv) { Materialize(*GVs[i]); } else { // Deleting. Materialize every GV that's *not* in GVs. - SmallPtrSet GVSet(GVs.begin(), GVs.end()); + SmallPtrSet GVSet(llvm::from_range, GVs); for (auto &F : *M) { if (!GVSet.count(&F)) Materialize(F); diff --git a/llvm/unittests/ADT/DirectedGraphTest.cpp b/llvm/unittests/ADT/DirectedGraphTest.cpp index ae1f6b01ef2d3..49ccf06ddc00c 100644 --- a/llvm/unittests/ADT/DirectedGraphTest.cpp +++ b/llvm/unittests/ADT/DirectedGraphTest.cpp @@ -271,7 +271,7 @@ TEST(DirectedGraphTest, SCC) { using NodeListTy = SmallPtrSet; SmallVector ListOfSCCs; for (auto &SCC : make_range(scc_begin(&DG), scc_end(&DG))) - ListOfSCCs.push_back(NodeListTy(SCC.begin(), SCC.end())); + ListOfSCCs.push_back(NodeListTy(llvm::from_range, SCC)); EXPECT_TRUE(ListOfSCCs.size() == 2);