Skip to content

[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
merged 1 commit into from
Mar 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion llvm/include/llvm/Support/GenericDomTreeConstruction.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/Transforms/Utils/FunctionImportUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Analysis/DependenceGraphBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Analysis/LazyCallGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions llvm/lib/Analysis/MemorySSAUpdater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Analysis/ScalarEvolution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/CodeGen/RDFGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/CodeGen/RDFLiveness.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/IR/DIBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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}});
}
}

Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/IR/VFABIDemangler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Object/IRSymtab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/AMDGPU/AMDGPUSwLowerLDS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
6 changes: 3 additions & 3 deletions llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
Expand Down Expand Up @@ -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]);
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion llvm/tools/llvm-extract/llvm-extract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion llvm/unittests/ADT/DirectedGraphTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down