Skip to content

Commit d4427f3

Browse files
[llvm] Use range constructors of *Set (NFC) (#133549)
1 parent b33cc64 commit d4427f3

File tree

16 files changed

+20
-20
lines changed

16 files changed

+20
-20
lines changed

llvm/include/llvm/Support/GenericDomTreeConstruction.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ struct SemiNCAInfo {
697697
const SmallVectorImpl<NodePtr> &B) {
698698
if (A.size() != B.size())
699699
return false;
700-
SmallPtrSet<NodePtr, 4> Set(A.begin(), A.end());
700+
SmallPtrSet<NodePtr, 4> Set(llvm::from_range, A);
701701
for (NodePtr N : B)
702702
if (Set.count(N) == 0)
703703
return false;

llvm/include/llvm/Transforms/Utils/FunctionImportUtils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ class FunctionImportGlobalProcessing {
116116
collectUsedGlobalVariables(M, Vec, /*CompilerUsed=*/false);
117117
// Next collect those in the llvm.compiler.used set.
118118
collectUsedGlobalVariables(M, Vec, /*CompilerUsed=*/true);
119-
Used = {Vec.begin(), Vec.end()};
119+
Used = {llvm::from_range, Vec};
120120
#endif
121121
}
122122

llvm/lib/Analysis/DependenceGraphBuilder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ template <class G> void AbstractDependenceGraphBuilder<G>::createPiBlocks() {
131131

132132
// Build a set to speed up the lookup for edges whose targets
133133
// are inside the SCC.
134-
SmallPtrSet<NodeType *, 4> NodesInSCC(NL.begin(), NL.end());
134+
SmallPtrSet<NodeType *, 4> NodesInSCC(llvm::from_range, NL);
135135

136136
// We have the set of nodes in the SCC. We go through the set of nodes
137137
// that are outside of the SCC and look for edges that cross the two sets.

llvm/lib/Analysis/LazyCallGraph.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1084,7 +1084,7 @@ LazyCallGraph::RefSCC::insertIncomingRefEdge(Node &SourceN, Node &TargetN) {
10841084

10851085
// Build a set, so we can do fast tests for whether a RefSCC will end up as
10861086
// part of the merged RefSCC.
1087-
SmallPtrSet<RefSCC *, 16> MergeSet(MergeRange.begin(), MergeRange.end());
1087+
SmallPtrSet<RefSCC *, 16> MergeSet(llvm::from_range, MergeRange);
10881088

10891089
// This RefSCC will always be part of that set, so just insert it here.
10901090
MergeSet.insert(this);

llvm/lib/Analysis/MemorySSAUpdater.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,8 +1083,8 @@ void MemorySSAUpdater::applyInsertUpdates(ArrayRef<CFGUpdate> Updates,
10831083
SmallVector<BasicBlock *, 32> IDFBlocks;
10841084
if (!BlocksToProcess.empty()) {
10851085
ForwardIDFCalculator IDFs(DT, GD);
1086-
SmallPtrSet<BasicBlock *, 16> DefiningBlocks(BlocksToProcess.begin(),
1087-
BlocksToProcess.end());
1086+
SmallPtrSet<BasicBlock *, 16> DefiningBlocks(llvm::from_range,
1087+
BlocksToProcess);
10881088
IDFs.setDefiningBlocks(DefiningBlocks);
10891089
IDFs.calculate(IDFBlocks);
10901090

@@ -1265,7 +1265,7 @@ void MemorySSAUpdater::wireOldPredecessorsToNewImmediatePredecessor(
12651265
assert(!Preds.empty() && "Must be moving at least one predecessor to the "
12661266
"new immediate predecessor.");
12671267
MemoryPhi *NewPhi = MSSA->createMemoryPhi(New);
1268-
SmallPtrSet<BasicBlock *, 16> PredsSet(Preds.begin(), Preds.end());
1268+
SmallPtrSet<BasicBlock *, 16> PredsSet(llvm::from_range, Preds);
12691269
// Currently only support the case of removing a single incoming edge when
12701270
// identical edges were not merged.
12711271
if (!IdenticalEdgesWereMerged)

llvm/lib/Analysis/ScalarEvolution.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14217,7 +14217,7 @@ void ScalarEvolution::forgetBackedgeTakenCounts(const Loop *L,
1421714217
}
1421814218

1421914219
void ScalarEvolution::forgetMemoizedResults(ArrayRef<const SCEV *> SCEVs) {
14220-
SmallPtrSet<const SCEV *, 8> ToForget(SCEVs.begin(), SCEVs.end());
14220+
SmallPtrSet<const SCEV *, 8> ToForget(llvm::from_range, SCEVs);
1422114221
SmallVector<const SCEV *, 8> Worklist(ToForget.begin(), ToForget.end());
1422214222

1422314223
while (!Worklist.empty()) {

llvm/lib/CodeGen/RDFGraph.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1415,7 +1415,7 @@ void DataFlowGraph::recordDefsForDF(BlockRefsMap &PhiM,
14151415

14161416
// Calculate the iterated dominance frontier of BB.
14171417
const MachineDominanceFrontier::DomSetType &DF = DFLoc->second;
1418-
SetVector<MachineBasicBlock *> IDF(DF.begin(), DF.end());
1418+
SetVector<MachineBasicBlock *> IDF(llvm::from_range, DF);
14191419
for (unsigned i = 0; i < IDF.size(); ++i) {
14201420
auto F = MDF.find(IDF[i]);
14211421
if (F != MDF.end())

llvm/lib/CodeGen/RDFLiveness.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,7 @@ void Liveness::computeLiveIns() {
759759
auto F1 = MDF.find(&B);
760760
if (F1 == MDF.end())
761761
continue;
762-
SetVector<MachineBasicBlock *> IDFB(F1->second.begin(), F1->second.end());
762+
SetVector<MachineBasicBlock *> IDFB(llvm::from_range, F1->second);
763763
for (unsigned i = 0; i < IDFB.size(); ++i) {
764764
auto F2 = MDF.find(IDFB[i]);
765765
if (F2 != MDF.end())

llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4864,7 +4864,7 @@ static void redirectAllPredecessorsTo(BasicBlock *OldTarget,
48644864
/// Determine which blocks in \p BBs are reachable from outside and remove the
48654865
/// ones that are not reachable from the function.
48664866
static void removeUnusedBlocksFromParent(ArrayRef<BasicBlock *> BBs) {
4867-
SmallPtrSet<BasicBlock *, 6> BBsToErase{BBs.begin(), BBs.end()};
4867+
SmallPtrSet<BasicBlock *, 6> BBsToErase(llvm::from_range, BBs);
48684868
auto HasRemainingUses = [&BBsToErase](BasicBlock *BB) {
48694869
for (Use &U : BB->uses()) {
48704870
auto *UseInst = dyn_cast<Instruction>(U.getUser());

llvm/lib/IR/DIBuilder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ DIBuilder::DIBuilder(Module &m, bool AllowUnresolvedNodes, DICompileUnit *CU)
3838
if (const auto &IMs = CUNode->getImportedEntities())
3939
ImportedModules.assign(IMs.begin(), IMs.end());
4040
if (const auto &MNs = CUNode->getMacros())
41-
AllMacrosPerParent.insert({nullptr, {MNs.begin(), MNs.end()}});
41+
AllMacrosPerParent.insert({nullptr, {llvm::from_range, MNs}});
4242
}
4343
}
4444

llvm/lib/IR/VFABIDemangler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ void VFABI::getVectorVariantNames(
541541
SmallVector<StringRef, 8> ListAttr;
542542
S.split(ListAttr, ",");
543543

544-
for (const auto &S : SetVector<StringRef>(ListAttr.begin(), ListAttr.end())) {
544+
for (const auto &S : SetVector<StringRef>(llvm::from_range, ListAttr)) {
545545
std::optional<VFInfo> Info =
546546
VFABI::tryDemangleForVFABI(S, CI.getFunctionType());
547547
if (Info && CI.getModule()->getFunction(Info->VectorName)) {

llvm/lib/Object/IRSymtab.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ Error Builder::addModule(Module *M) {
140140
SmallVector<GlobalValue *, 4> UsedV;
141141
collectUsedGlobalVariables(*M, UsedV, /*CompilerUsed=*/false);
142142
collectUsedGlobalVariables(*M, UsedV, /*CompilerUsed=*/true);
143-
SmallPtrSet<GlobalValue *, 4> Used(UsedV.begin(), UsedV.end());
143+
SmallPtrSet<GlobalValue *, 4> Used(llvm::from_range, UsedV);
144144

145145
ModuleSymbolTable Msymtab;
146146
Msymtab.addModule(M);

llvm/lib/Target/AMDGPU/AMDGPUSwLowerLDS.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ template <typename T> SetVector<T> sortByName(std::vector<T> &&V) {
227227
sort(V, [](const auto *L, const auto *R) {
228228
return L->getName() < R->getName();
229229
});
230-
return {SetVector<T>(V.begin(), V.end())};
230+
return {SetVector<T>(llvm::from_range, V)};
231231
}
232232

233233
SetVector<GlobalVariable *> AMDGPUSwLowerLDS::getOrderedNonKernelAllLDSGlobals(

llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1331,7 +1331,7 @@ bool PolynomialMultiplyRecognize::convertShiftsToLeft(BasicBlock *LoopB,
13311331

13321332
// Find the set of all values affected by the shift cycles, i.e. all
13331333
// cycled values, and (recursively) all their users.
1334-
ValueSeq Users(Cycled.begin(), Cycled.end());
1334+
ValueSeq Users(llvm::from_range, Cycled);
13351335
for (unsigned i = 0; i < Users.size(); ++i) {
13361336
Value *V = Users[i];
13371337
if (!isa<IntegerType>(V->getType()))
@@ -1359,7 +1359,7 @@ bool PolynomialMultiplyRecognize::convertShiftsToLeft(BasicBlock *LoopB,
13591359
return false;
13601360

13611361
// Verify that high bits remain zero.
1362-
ValueSeq Internal(Users.begin(), Users.end());
1362+
ValueSeq Internal(llvm::from_range, Users);
13631363
ValueSeq Inputs;
13641364
for (unsigned i = 0; i < Internal.size(); ++i) {
13651365
auto *R = dyn_cast<Instruction>(Internal[i]);
@@ -2305,7 +2305,7 @@ bool HexagonLoopIdiomRecognize::coverLoop(Loop *L,
23052305
SmallSet<BasicBlock*,8> LoopBlocks;
23062306
LoopBlocks.insert_range(L->blocks());
23072307

2308-
SetVector<Instruction*> Worklist(Insts.begin(), Insts.end());
2308+
SetVector<Instruction *> Worklist(llvm::from_range, Insts);
23092309

23102310
// Collect all instructions from the loop that the instructions in Insts
23112311
// depend on (plus their dependencies, etc.). These instructions will

llvm/tools/llvm-extract/llvm-extract.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ int main(int argc, char **argv) {
313313
Materialize(*GVs[i]);
314314
} else {
315315
// Deleting. Materialize every GV that's *not* in GVs.
316-
SmallPtrSet<GlobalValue *, 8> GVSet(GVs.begin(), GVs.end());
316+
SmallPtrSet<GlobalValue *, 8> GVSet(llvm::from_range, GVs);
317317
for (auto &F : *M) {
318318
if (!GVSet.count(&F))
319319
Materialize(F);

llvm/unittests/ADT/DirectedGraphTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ TEST(DirectedGraphTest, SCC) {
271271
using NodeListTy = SmallPtrSet<DGTestNode *, 3>;
272272
SmallVector<NodeListTy, 4> ListOfSCCs;
273273
for (auto &SCC : make_range(scc_begin(&DG), scc_end(&DG)))
274-
ListOfSCCs.push_back(NodeListTy(SCC.begin(), SCC.end()));
274+
ListOfSCCs.push_back(NodeListTy(llvm::from_range, SCC));
275275

276276
EXPECT_TRUE(ListOfSCCs.size() == 2);
277277

0 commit comments

Comments
 (0)