Skip to content

[llvm] Use *Set::insert_range (NFC) #133353

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
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
3 changes: 1 addition & 2 deletions llvm/lib/CodeGen/CodeGenPrepare.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4370,8 +4370,7 @@ class AddressingModeCombiner {
// If it does not match, collect all Phi nodes from matcher.
// if we end up with no match, them all these Phi nodes will not match
// later.
for (auto M : Matched)
WillNotMatch.insert(M.first);
WillNotMatch.insert_range(llvm::make_first_range(Matched));
Matched.clear();
}
if (IsMatched) {
Expand Down
3 changes: 1 addition & 2 deletions llvm/lib/CodeGen/FixupStatepointCallerSaved.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,7 @@ class FrameIndexesCache {
ReservedSlots.clear();
if (EHPad)
if (auto It = GlobalIndices.find(EHPad); It != GlobalIndices.end())
for (auto &RSP : It->second)
ReservedSlots.insert(RSP.second);
ReservedSlots.insert_range(llvm::make_second_range(It->second));
}

// Get frame index to spill the register.
Expand Down
5 changes: 2 additions & 3 deletions llvm/lib/IR/SafepointIRVerifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -612,11 +612,10 @@ void GCPtrTracker::verifyFunction(GCPtrTracker &&Tracker,
}

void GCPtrTracker::recalculateBBsStates() {
SetVector<const BasicBlock *> Worklist;
// TODO: This order is suboptimal, it's better to replace it with priority
// queue where priority is RPO number of BB.
for (auto &BBI : BlockMap)
Worklist.insert(BBI.first);
SetVector<const BasicBlock *> Worklist(llvm::from_range,
llvm::make_first_range(BlockMap));

// This loop iterates the AvailableIn/Out sets until it converges.
// The AvailableIn and AvailableOut sets decrease as we iterate.
Expand Down
3 changes: 1 addition & 2 deletions llvm/lib/ProfileData/SampleProf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,7 @@ const FunctionSamples *FunctionSamples::findFunctionSamples(
void FunctionSamples::findAllNames(DenseSet<FunctionId> &NameSet) const {
NameSet.insert(getFunction());
for (const auto &BS : BodySamples)
for (const auto &TS : BS.second.getCallTargets())
NameSet.insert(TS.first);
NameSet.insert_range(llvm::make_first_range(BS.second.getCallTargets()));

for (const auto &CS : CallsiteSamples) {
for (const auto &NameFS : CS.second) {
Expand Down
10 changes: 3 additions & 7 deletions llvm/lib/Transforms/Scalar/JumpThreading.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -524,9 +524,7 @@ static unsigned getJumpThreadDuplicationCost(const TargetTransformInfo *TTI,
void JumpThreadingPass::findLoopHeaders(Function &F) {
SmallVector<std::pair<const BasicBlock*,const BasicBlock*>, 32> Edges;
FindFunctionBackedges(F, Edges);

for (const auto &Edge : Edges)
LoopHeaders.insert(Edge.second);
LoopHeaders.insert_range(llvm::make_second_range(Edges));
}

/// getKnownConstant - Helper method to determine if we can thread over a
Expand Down Expand Up @@ -1379,10 +1377,8 @@ bool JumpThreadingPass::simplifyPartiallyRedundantLoad(LoadInst *LoadI) {
// Otherwise, we had multiple unavailable predecessors or we had a critical
// edge from the one.
SmallVector<BasicBlock*, 8> PredsToSplit;
SmallPtrSet<BasicBlock*, 8> AvailablePredSet;

for (const auto &AvailablePred : AvailablePreds)
AvailablePredSet.insert(AvailablePred.first);
SmallPtrSet<BasicBlock *, 8> AvailablePredSet(
llvm::from_range, llvm::make_first_range(AvailablePreds));

// Add all the unavailable predecessors to the PredsToSplit list.
for (BasicBlock *P : predecessors(LoadBB)) {
Expand Down
3 changes: 1 addition & 2 deletions llvm/lib/Transforms/Scalar/StructurizeCFG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -819,8 +819,7 @@ void StructurizeCFG::setPhiValues() {

// Get the undefined blocks shared by all the phi nodes.
if (!BlkPhis.empty()) {
for (const auto &VI : BlkPhis.front().second)
Incomings.insert(VI.first);
Incomings.insert_range(llvm::make_first_range(BlkPhis.front().second));
findUndefBlocks(To, Incomings, UndefBlks);
}

Expand Down
9 changes: 3 additions & 6 deletions llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6896,8 +6896,7 @@ void BoUpSLP::reorderBottomToTop(bool IgnoreReorder) {
SmallVector<TreeEntry *> GatherOps;
if (!canReorderOperands(Data.first, Data.second, NonVectorized,
GatherOps)) {
for (const std::pair<unsigned, TreeEntry *> &Op : Data.second)
Visited.insert(Op.second);
Visited.insert_range(llvm::make_second_range(Data.second));
continue;
}
// All operands are reordered and used only in this node - propagate the
Expand Down Expand Up @@ -7073,8 +7072,7 @@ void BoUpSLP::reorderBottomToTop(bool IgnoreReorder) {
}
}
if (OrdersUses.empty()) {
for (const std::pair<unsigned, TreeEntry *> &Op : Data.second)
Visited.insert(Op.second);
Visited.insert_range(llvm::make_second_range(Data.second));
continue;
}
// Choose the most used order.
Expand Down Expand Up @@ -7103,8 +7101,7 @@ void BoUpSLP::reorderBottomToTop(bool IgnoreReorder) {
}
// Set order of the user node.
if (isIdentityOrder(BestOrder)) {
for (const std::pair<unsigned, TreeEntry *> &Op : Data.second)
Visited.insert(Op.second);
Visited.insert_range(llvm::make_second_range(Data.second));
continue;
}
fixupOrderingIndices(BestOrder);
Expand Down
5 changes: 2 additions & 3 deletions llvm/lib/Transforms/Vectorize/VPlanSLP.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,9 @@ class VPInterleavedAccessInfo {
VPInterleavedAccessInfo(VPlan &Plan, InterleavedAccessInfo &IAI);

~VPInterleavedAccessInfo() {
SmallPtrSet<InterleaveGroup<VPInstruction> *, 4> DelSet;
// Avoid releasing a pointer twice.
for (auto &I : InterleaveGroupMap)
DelSet.insert(I.second);
SmallPtrSet<InterleaveGroup<VPInstruction> *, 4> DelSet(
llvm::from_range, llvm::make_second_range(InterleaveGroupMap));
for (auto *Ptr : DelSet)
delete Ptr;
}
Expand Down
6 changes: 2 additions & 4 deletions llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,8 @@ bool TypeSetByHwMode::operator==(const TypeSetByHwMode &VTS) const {
return false;

SmallSet<unsigned, 4> Modes;
for (auto &I : *this)
Modes.insert(I.first);
for (const auto &I : VTS)
Modes.insert(I.first);
Modes.insert_range(llvm::make_first_range(*this));
Modes.insert_range(llvm::make_first_range(VTS));

if (HaveDefault) {
// Both sets have default mode.
Expand Down
3 changes: 1 addition & 2 deletions llvm/utils/TableGen/Common/CodeGenRegisters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -598,8 +598,7 @@ void CodeGenRegister::addSubRegsPreOrder(
SR->addSubRegsPreOrder(OSet, RegBank);
}
// Add any secondary sub-registers that weren't part of the explicit tree.
for (auto SubReg : SubRegs)
OSet.insert(SubReg.second);
OSet.insert_range(llvm::make_second_range(SubRegs));
}

// Get the sum of this register's unit weights.
Expand Down
Loading