-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[llvm] Use range constructors of *Set (NFC) #133549
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
kazutakahirata
merged 1 commit into
llvm:main
from
kazutakahirata:cleanup_001_set_range_llvm
Mar 29, 2025
Merged
[llvm] Use range constructors of *Set (NFC) #133549
kazutakahirata
merged 1 commit into
llvm:main
from
kazutakahirata:cleanup_001_set_range_llvm
Mar 29, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@llvm/pr-subscribers-llvm-transforms @llvm/pr-subscribers-flang-openmp Author: Kazu Hirata (kazutakahirata) ChangesFull diff: https://github.com/llvm/llvm-project/pull/133549.diff 16 Files Affected:
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<NodePtr> &B) {
if (A.size() != B.size())
return false;
- SmallPtrSet<NodePtr, 4> Set(A.begin(), A.end());
+ SmallPtrSet<NodePtr, 4> 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 <class G> void AbstractDependenceGraphBuilder<G>::createPiBlocks() {
// Build a set to speed up the lookup for edges whose targets
// are inside the SCC.
- SmallPtrSet<NodeType *, 4> NodesInSCC(NL.begin(), NL.end());
+ SmallPtrSet<NodeType *, 4> 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<RefSCC *, 16> MergeSet(MergeRange.begin(), MergeRange.end());
+ SmallPtrSet<RefSCC *, 16> 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<CFGUpdate> Updates,
SmallVector<BasicBlock *, 32> IDFBlocks;
if (!BlocksToProcess.empty()) {
ForwardIDFCalculator IDFs(DT, GD);
- SmallPtrSet<BasicBlock *, 16> DefiningBlocks(BlocksToProcess.begin(),
- BlocksToProcess.end());
+ SmallPtrSet<BasicBlock *, 16> 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<BasicBlock *, 16> PredsSet(Preds.begin(), Preds.end());
+ SmallPtrSet<BasicBlock *, 16> 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<const SCEV *> SCEVs) {
- SmallPtrSet<const SCEV *, 8> ToForget(SCEVs.begin(), SCEVs.end());
+ SmallPtrSet<const SCEV *, 8> ToForget(llvm::from_range, SCEVs);
SmallVector<const SCEV *, 8> 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<MachineBasicBlock *> IDF(DF.begin(), DF.end());
+ SetVector<MachineBasicBlock *> 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<MachineBasicBlock *> IDFB(F1->second.begin(), F1->second.end());
+ SetVector<MachineBasicBlock *> 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<BasicBlock *> BBs) {
- SmallPtrSet<BasicBlock *, 6> BBsToErase{BBs.begin(), BBs.end()};
+ SmallPtrSet<BasicBlock *, 6> BBsToErase(llvm::from_range, BBs);
auto HasRemainingUses = [&BBsToErase](BasicBlock *BB) {
for (Use &U : BB->uses()) {
auto *UseInst = dyn_cast<Instruction>(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<StringRef, 8> ListAttr;
S.split(ListAttr, ",");
- for (const auto &S : SetVector<StringRef>(ListAttr.begin(), ListAttr.end())) {
+ for (const auto &S : SetVector<StringRef>(llvm::from_range, ListAttr)) {
std::optional<VFInfo> 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<GlobalValue *, 4> UsedV;
collectUsedGlobalVariables(*M, UsedV, /*CompilerUsed=*/false);
collectUsedGlobalVariables(*M, UsedV, /*CompilerUsed=*/true);
- SmallPtrSet<GlobalValue *, 4> Used(UsedV.begin(), UsedV.end());
+ SmallPtrSet<GlobalValue *, 4> 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 <typename T> SetVector<T> sortByName(std::vector<T> &&V) {
sort(V, [](const auto *L, const auto *R) {
return L->getName() < R->getName();
});
- return {SetVector<T>(V.begin(), V.end())};
+ return {SetVector<T>(llvm::from_range, V)};
}
SetVector<GlobalVariable *> 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<IntegerType>(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<Instruction>(Internal[i]);
@@ -2305,7 +2305,7 @@ bool HexagonLoopIdiomRecognize::coverLoop(Loop *L,
SmallSet<BasicBlock*,8> LoopBlocks;
LoopBlocks.insert_range(L->blocks());
- SetVector<Instruction*> Worklist(Insts.begin(), Insts.end());
+ SetVector<Instruction *> 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<GlobalValue *, 8> GVSet(GVs.begin(), GVs.end());
+ SmallPtrSet<GlobalValue *, 8> 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<DGTestNode *, 3>;
SmallVector<NodeListTy, 4> 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);
|
kuhar
approved these changes
Mar 29, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
backend:AMDGPU
backend:Hexagon
clang:openmp
OpenMP related changes to Clang
flang:openmp
llvm:adt
llvm:analysis
Includes value tracking, cost tables and constant folding
llvm:binary-utilities
llvm:ir
llvm:support
llvm:transforms
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.