Skip to content

Commit 7193528

Browse files
[Target] Use *Set::insert_range (NFC) (#132140)
DenseSet, SmallPtrSet, SmallSet, SetVector, and StringSet recently gained C++23-style insert_range. This patch replaces: Dest.insert(Src.begin(), Src.end()); with: Dest.insert_range(Src); This patch does not touch custom begin like succ_begin for now.
1 parent 7c1f473 commit 7193528

20 files changed

+33
-33
lines changed

llvm/lib/Target/AArch64/AArch64MachineFunctionInfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ class AArch64FunctionInfo final : public MachineFunctionInfo {
495495
/// Add a LOH directive of this @p Kind and this @p Args.
496496
void addLOHDirective(MCLOHType Kind, MILOHArgs Args) {
497497
LOHContainerSet.push_back(MILOHDirective(Kind, Args));
498-
LOHRelated.insert(Args.begin(), Args.end());
498+
LOHRelated.insert_range(Args);
499499
}
500500

501501
SmallVectorImpl<ForwardedRegister> &getForwardedMustTailRegParms() {

llvm/lib/Target/AArch64/AArch64Subtarget.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ AArch64Subtarget::AArch64Subtarget(const Triple &TT, StringRef CPU,
395395

396396
auto TRI = getRegisterInfo();
397397
StringSet<> ReservedRegNames;
398-
ReservedRegNames.insert(ReservedRegsForRA.begin(), ReservedRegsForRA.end());
398+
ReservedRegNames.insert_range(ReservedRegsForRA);
399399
for (unsigned i = 0; i < 29; ++i) {
400400
if (ReservedRegNames.count(TRI->getName(AArch64::X0 + i)))
401401
ReserveXRegisterForRA.set(i);

llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1042,7 +1042,7 @@ bool AMDGPUPromoteAllocaImpl::tryPromoteAllocaToVector(AllocaInst &Alloca) {
10421042
// Delete all instructions. On the first pass, new dummy loads may have been
10431043
// added so we need to collect them too.
10441044
DenseSet<Instruction *> InstsToDelete(WorkList.begin(), WorkList.end());
1045-
InstsToDelete.insert(DeferredLoads.begin(), DeferredLoads.end());
1045+
InstsToDelete.insert_range(DeferredLoads);
10461046
for (Instruction *I : InstsToDelete) {
10471047
assert(I->use_empty());
10481048
I->eraseFromParent();

llvm/lib/Target/AMDGPU/AMDGPUSplitModule.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ void SplitGraph::buildGraph(CallGraph &CG) {
569569
LLVM_DEBUG(dbgs() << " indirect call found\n");
570570
FnsWithIndirectCalls.push_back(&Fn);
571571
} else if (!KnownCallees.empty())
572-
DirectCallees.insert(KnownCallees.begin(), KnownCallees.end());
572+
DirectCallees.insert_range(KnownCallees);
573573
}
574574

575575
Node &N = getNode(Cache, Fn);

llvm/lib/Target/AMDGPU/GCNSchedStrategy.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1795,7 +1795,7 @@ bool PreRARematStage::sinkTriviallyRematInsts(const GCNSubtarget &ST,
17951795
// Collect only regions that has a rematerializable def as a live-in.
17961796
SmallSet<unsigned, 16> ImpactedRegions;
17971797
for (const auto &It : RematDefToLiveInRegions)
1798-
ImpactedRegions.insert(It.second.begin(), It.second.end());
1798+
ImpactedRegions.insert_range(It.second);
17991799

18001800
// Make copies of register pressure and live-ins cache that will be updated
18011801
// as we rematerialize.

llvm/lib/Target/ARM/ARMConstantPoolValue.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ int ARMConstantPoolConstant::getExistingMachineCPValue(MachineConstantPool *CP,
196196
auto *CPV = static_cast<ARMConstantPoolValue*>(
197197
CP->getConstants()[index].Val.MachineCPVal);
198198
auto *Constant = cast<ARMConstantPoolConstant>(CPV);
199-
Constant->GVars.insert(GVars.begin(), GVars.end());
199+
Constant->GVars.insert_range(GVars);
200200
}
201201
return index;
202202
}

llvm/lib/Target/ARM/ARMLowOverheadLoops.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ static bool TryRemove(MachineInstr *MI, ReachingDefAnalysis &RDA,
568568
}
569569
if (!ModifiedITs.empty())
570570
return false;
571-
Killed.insert(RemoveITs.begin(), RemoveITs.end());
571+
Killed.insert_range(RemoveITs);
572572
return true;
573573
};
574574

@@ -577,7 +577,7 @@ static bool TryRemove(MachineInstr *MI, ReachingDefAnalysis &RDA,
577577
return false;
578578

579579
if (WontCorruptITs(Uses, RDA)) {
580-
ToRemove.insert(Uses.begin(), Uses.end());
580+
ToRemove.insert_range(Uses);
581581
LLVM_DEBUG(dbgs() << "ARM Loops: Able to remove: " << *MI
582582
<< " - can also remove:\n";
583583
for (auto *Use : Uses)
@@ -586,7 +586,7 @@ static bool TryRemove(MachineInstr *MI, ReachingDefAnalysis &RDA,
586586
SmallPtrSet<MachineInstr*, 4> Killed;
587587
RDA.collectKilledOperands(MI, Killed);
588588
if (WontCorruptITs(Killed, RDA)) {
589-
ToRemove.insert(Killed.begin(), Killed.end());
589+
ToRemove.insert_range(Killed);
590590
LLVM_DEBUG(for (auto *Dead : Killed)
591591
dbgs() << " - " << *Dead);
592592
}
@@ -759,7 +759,7 @@ bool LowOverheadLoop::ValidateTailPredicate() {
759759
SmallPtrSet<MachineInstr*, 2> Ignore;
760760
unsigned ExpectedVectorWidth = getTailPredVectorWidth(VCTP->getOpcode());
761761

762-
Ignore.insert(VCTPs.begin(), VCTPs.end());
762+
Ignore.insert_range(VCTPs);
763763

764764
if (TryRemove(Def, RDA, ElementChain, Ignore)) {
765765
bool FoundSub = false;
@@ -781,7 +781,7 @@ bool LowOverheadLoop::ValidateTailPredicate() {
781781
return false;
782782
}
783783
}
784-
ToRemove.insert(ElementChain.begin(), ElementChain.end());
784+
ToRemove.insert_range(ElementChain);
785785
}
786786
}
787787

@@ -795,7 +795,7 @@ bool LowOverheadLoop::ValidateTailPredicate() {
795795
if (auto *Def = RDA.getUniqueReachingMIDef(
796796
&Preheader->back(), VCTP->getOperand(1).getReg().asMCReg())) {
797797
SmallPtrSet<MachineInstr*, 2> Ignore;
798-
Ignore.insert(VCTPs.begin(), VCTPs.end());
798+
Ignore.insert_range(VCTPs);
799799
TryRemove(Def, RDA, ToRemove, Ignore);
800800
}
801801
}
@@ -1693,7 +1693,7 @@ void ARMLowOverheadLoops::ConvertVPTBlocks(LowOverheadLoop &LoLoop) {
16931693
}
16941694
}
16951695

1696-
LoLoop.ToRemove.insert(LoLoop.VCTPs.begin(), LoLoop.VCTPs.end());
1696+
LoLoop.ToRemove.insert_range(LoLoop.VCTPs);
16971697
}
16981698

16991699
void ARMLowOverheadLoops::Expand(LowOverheadLoop &LoLoop) {

llvm/lib/Target/ARM/ARMParallelDSP.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ bool ARMParallelDSP::MatchSMLAD(Function &F) {
534534

535535
InsertParallelMACs(R);
536536
Changed = true;
537-
AllAdds.insert(R.getAdds().begin(), R.getAdds().end());
537+
AllAdds.insert_range(R.getAdds());
538538
LLVM_DEBUG(dbgs() << "BB after inserting parallel MACs:\n" << BB);
539539
}
540540
}

llvm/lib/Target/Hexagon/BitTracker.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -942,7 +942,7 @@ void BT::visitBranchesFrom(const MachineInstr &BI) {
942942
else
943943
dbgs() << "\n does not fall through\n";
944944
}
945-
Targets.insert(BTs.begin(), BTs.end());
945+
Targets.insert_range(BTs);
946946
}
947947
++It;
948948
} while (FallsThrough && It != End);

llvm/lib/Target/Hexagon/HexagonCommonGEP.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ void HexagonCommonGEP::processGepInst(GetElementPtrInst *GepI,
399399
// After last node has been created, update the use information.
400400
if (!Us.empty()) {
401401
PN->Flags |= GepNode::Used;
402-
Uses[PN].insert(Us.begin(), Us.end());
402+
Uses[PN].insert_range(Us);
403403
}
404404

405405
// Link the last node with the originating GEP instruction. This is to
@@ -606,7 +606,7 @@ void HexagonCommonGEP::common() {
606606
// original values of Min.
607607
if (NF & GepNode::Used) {
608608
auto &U = Uses[N];
609-
MinUs.insert(U.begin(), U.end());
609+
MinUs.insert_range(U);
610610
}
611611
Flags |= NF;
612612
}

llvm/lib/Target/Hexagon/HexagonConstExtenders.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1470,7 +1470,7 @@ void HCE::assignInits(const ExtRoot &ER, unsigned Begin, unsigned End,
14701470
ExtValue(ED).Offset == EV.Offset;
14711471
};
14721472
if (all_of(P.second, SameValue)) {
1473-
F->second.insert(P.second.begin(), P.second.end());
1473+
F->second.insert_range(P.second);
14741474
P.second.clear();
14751475
}
14761476
}

llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,9 @@ bool Coloring::color() {
195195
Q.insert(N);
196196
for (unsigned I = 0; I != Q.size(); ++I) {
197197
NodeSet &Ns = Edges[Q[I]];
198-
Q.insert(Ns.begin(), Ns.end());
198+
Q.insert_range(Ns);
199199
}
200-
FirstQ.insert(Q.begin(), Q.end());
200+
FirstQ.insert_range(Q);
201201
};
202202
for (Node N : Needed)
203203
Enqueue(N);

llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1325,7 +1325,7 @@ bool PolynomialMultiplyRecognize::convertShiftsToLeft(BasicBlock *LoopB,
13251325
// Found a cycle.
13261326
C.insert(&I);
13271327
classifyCycle(&I, C, Early, Late);
1328-
Cycled.insert(C.begin(), C.end());
1328+
Cycled.insert_range(C);
13291329
RShifts.insert(&I);
13301330
}
13311331

llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7236,7 +7236,7 @@ static bool PeepholePPC64ZExtGather(SDValue Op32,
72367236
return false;
72377237

72387238
ToPromote.insert(Op32.getNode());
7239-
ToPromote.insert(ToPromote1.begin(), ToPromote1.end());
7239+
ToPromote.insert_range(ToPromote1);
72407240
return true;
72417241
}
72427242

@@ -7253,7 +7253,7 @@ static bool PeepholePPC64ZExtGather(SDValue Op32,
72537253
return false;
72547254

72557255
ToPromote.insert(Op32.getNode());
7256-
ToPromote.insert(ToPromote1.begin(), ToPromote1.end());
7256+
ToPromote.insert_range(ToPromote1);
72577257
return true;
72587258
}
72597259

@@ -7269,7 +7269,7 @@ static bool PeepholePPC64ZExtGather(SDValue Op32,
72697269
return false;
72707270

72717271
ToPromote.insert(Op32.getNode());
7272-
ToPromote.insert(ToPromote1.begin(), ToPromote1.end());
7272+
ToPromote.insert_range(ToPromote1);
72737273
return true;
72747274
}
72757275

@@ -7287,10 +7287,10 @@ static bool PeepholePPC64ZExtGather(SDValue Op32,
72877287
ToPromote.insert(Op32.getNode());
72887288

72897289
if (Op0OK)
7290-
ToPromote.insert(ToPromote1.begin(), ToPromote1.end());
7290+
ToPromote.insert_range(ToPromote1);
72917291

72927292
if (Op1OK)
7293-
ToPromote.insert(ToPromote2.begin(), ToPromote2.end());
7293+
ToPromote.insert_range(ToPromote2);
72947294

72957295
return true;
72967296
}
@@ -7310,7 +7310,7 @@ static bool PeepholePPC64ZExtGather(SDValue Op32,
73107310
ToPromote.insert(Op32.getNode());
73117311

73127312
if (Op0OK)
7313-
ToPromote.insert(ToPromote1.begin(), ToPromote1.end());
7313+
ToPromote.insert_range(ToPromote1);
73147314

73157315
return true;
73167316
}

llvm/lib/Target/SPIRV/Analysis/SPIRVConvergenceRegionAnalysis.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ class ConvergenceRegionAnalyzer {
284284
return false;
285285
return Token.value() == CT.value();
286286
});
287-
RegionBlocks.insert(N.begin(), N.end());
287+
RegionBlocks.insert_range(N);
288288
}
289289
}
290290

llvm/lib/Target/SPIRV/SPIRVModuleAnalysis.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ struct RequirementHandler {
100100
void addCapabilities(const CapabilityList &ToAdd);
101101
void addCapability(Capability::Capability ToAdd) { addCapabilities({ToAdd}); }
102102
void addExtensions(const ExtensionList &ToAdd) {
103-
AllExtensions.insert(ToAdd.begin(), ToAdd.end());
103+
AllExtensions.insert_range(ToAdd);
104104
}
105105
void addExtension(Extension::Extension ToAdd) { AllExtensions.insert(ToAdd); }
106106
// Add the given requirements to the lists. If constraints conflict, or these

llvm/lib/Target/SPIRV/SPIRVSubtarget.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ void SPIRVSubtarget::initAvailableExtInstSets() {
160160
void SPIRVSubtarget::initAvailableExtensions(
161161
const std::set<SPIRV::Extension::Extension> &AllowedExtIds) {
162162
AvailableExtensions.clear();
163-
AvailableExtensions.insert(AllowedExtIds.begin(), AllowedExtIds.end());
163+
AvailableExtensions.insert_range(AllowedExtIds);
164164

165165
accountForAMDShaderTrinaryMinmax();
166166
}

llvm/lib/Target/SystemZ/SystemZRegisterInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ static void addHints(ArrayRef<MCPhysReg> Order,
5959
const TargetRegisterClass *RC,
6060
const MachineRegisterInfo *MRI) {
6161
SmallSet<unsigned, 4> CopyHints;
62-
CopyHints.insert(Hints.begin(), Hints.end());
62+
CopyHints.insert_range(Hints);
6363
Hints.clear();
6464
for (MCPhysReg Reg : Order)
6565
if (CopyHints.count(Reg) &&

llvm/lib/Target/X86/X86CmovConversion.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ bool X86CmovConverterPass::checkForProfitableCmovCandidates(
416416

417417
SmallPtrSet<MachineInstr *, 4> CmovInstructions;
418418
for (auto &Group : CmovInstGroups)
419-
CmovInstructions.insert(Group.begin(), Group.end());
419+
CmovInstructions.insert_range(Group);
420420

421421
//===--------------------------------------------------------------------===//
422422
// Step 1: Calculate instruction depth and loop depth.

llvm/lib/Target/X86/X86RegisterInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1214,7 +1214,7 @@ bool X86RegisterInfo::getRegAllocationHints(Register VirtReg,
12141214
};
12151215

12161216
SmallSet<MCPhysReg, 4> CopyHints;
1217-
CopyHints.insert(Hints.begin(), Hints.end());
1217+
CopyHints.insert_range(Hints);
12181218
Hints.clear();
12191219
for (auto Hint : CopyHints) {
12201220
if (RC.contains(Hint) && !MRI->isReserved(Hint))

0 commit comments

Comments
 (0)