Skip to content

Commit 7193528

Browse files
[Target] Use *Set::insert_range (NFC) (llvm#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
}

0 commit comments

Comments
 (0)