Skip to content

Commit 5990056

Browse files
[llvm] Use *Set::insert_range (NFC) (#132325)
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 13bb2f4 commit 5990056

25 files changed

+39
-42
lines changed

llvm/include/llvm/Analysis/IVDescriptors.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class RecurrenceDescriptor {
8787
Kind(K), FMF(FMF), ExactFPMathInst(ExactFP), RecurrenceType(RT),
8888
IsSigned(Signed), IsOrdered(Ordered),
8989
MinWidthCastToRecurrenceType(MinWidthCastToRecurTy) {
90-
CastInsts.insert(CI.begin(), CI.end());
90+
CastInsts.insert_range(CI);
9191
}
9292

9393
/// This POD struct holds information about a potential recurrence operation.

llvm/lib/Analysis/MemorySSA.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1573,7 +1573,7 @@ void MemorySSA::buildMemorySSA(BatchAAResults &BAA, IterT Blocks) {
15731573
// the loop, to limit the scope of the renaming.
15741574
SmallVector<BasicBlock *> ExitBlocks;
15751575
L->getExitBlocks(ExitBlocks);
1576-
Visited.insert(ExitBlocks.begin(), ExitBlocks.end());
1576+
Visited.insert_range(ExitBlocks);
15771577
renamePass(DT->getNode(L->getLoopPreheader()), LiveOnEntryDef.get(),
15781578
Visited);
15791579
} else {

llvm/lib/Analysis/PhiValues.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ void PhiValues::processPhi(const PHINode *Phi,
100100
if (OpDepthNumber != RootDepthNumber) {
101101
auto It = ReachableMap.find(OpDepthNumber);
102102
if (It != ReachableMap.end())
103-
Reachable.insert(It->second.begin(), It->second.end());
103+
Reachable.insert_range(It->second);
104104
}
105105
} else
106106
Reachable.insert(Op);

llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1170,7 +1170,7 @@ DIE *DwarfCompileUnit::createAndAddScopeChildren(LexicalScope *Scope,
11701170
// should be emitted for subprograms in this CU.
11711171
if (!includeMinimalInlineScopes() && !Scope->getInlinedAt()) {
11721172
auto &LocalDecls = DD->getLocalDeclsForScope(Scope->getScopeNode());
1173-
DeferredLocalDecls.insert(LocalDecls.begin(), LocalDecls.end());
1173+
DeferredLocalDecls.insert_range(LocalDecls);
11741174
}
11751175

11761176
// Emit inner lexical scopes.

llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -706,8 +706,7 @@ static void interpretValues(const MachineInstr *CurMI,
706706
getForwardingRegsDefinedByMI(*CurMI, FwdRegDefs);
707707
if (FwdRegDefs.empty()) {
708708
// Any definitions by this instruction will clobber earlier reg movements.
709-
ClobberedRegUnits.insert(NewClobberedRegUnits.begin(),
710-
NewClobberedRegUnits.end());
709+
ClobberedRegUnits.insert_range(NewClobberedRegUnits);
711710
return;
712711
}
713712

@@ -756,8 +755,7 @@ static void interpretValues(const MachineInstr *CurMI,
756755
ForwardedRegWorklist.erase(ParamFwdReg);
757756

758757
// Any definitions by this instruction will clobber earlier reg movements.
759-
ClobberedRegUnits.insert(NewClobberedRegUnits.begin(),
760-
NewClobberedRegUnits.end());
758+
ClobberedRegUnits.insert_range(NewClobberedRegUnits);
761759

762760
// Now that we are done handling this instruction, add items from the
763761
// temporary worklist to the real one.

llvm/lib/CodeGen/CodeGenPrepare.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7577,7 +7577,7 @@ bool CodeGenPrepare::optimizeSelectInst(SelectInst *SI) {
75777577
FalseBlock = StartBlock;
75787578

75797579
SmallPtrSet<const Instruction *, 2> INS;
7580-
INS.insert(ASI.begin(), ASI.end());
7580+
INS.insert_range(ASI);
75817581
// Use reverse iterator because later select may use the value of the
75827582
// earlier select, and we need to propagate value through earlier select
75837583
// to get the PHI operand.

llvm/lib/CodeGen/InlineSpiller.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1461,7 +1461,7 @@ void HoistSpillHelper::getVisitOrders(
14611461
// with BBs containing hoisted spills which will be inserted to
14621462
// SpillsToKeep later during hoisting.
14631463
SpillsToKeep[MDT[Block]] = Register();
1464-
WorkSet.insert(NodesOnPath.begin(), NodesOnPath.end());
1464+
WorkSet.insert_range(NodesOnPath);
14651465
}
14661466
NodesOnPath.clear();
14671467
}

llvm/lib/CodeGen/InterleavedAccessPass.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ bool InterleavedAccessImpl::lowerInterleavedLoad(
349349
return !Extracts.empty() || BinOpShuffleChanged;
350350
}
351351

352-
DeadInsts.insert(Shuffles.begin(), Shuffles.end());
352+
DeadInsts.insert_range(Shuffles);
353353

354354
DeadInsts.insert(LI);
355355
return true;
@@ -703,7 +703,7 @@ bool InterleavedAccessImpl::lowerDeinterleaveIntrinsic(
703703
return false;
704704
}
705705

706-
DeadInsts.insert(DeinterleaveDeadInsts.begin(), DeinterleaveDeadInsts.end());
706+
DeadInsts.insert_range(DeinterleaveDeadInsts);
707707
// We now have a target-specific load, so delete the old one.
708708
DeadInsts.insert(cast<Instruction>(LoadedVal));
709709
return true;
@@ -757,7 +757,7 @@ bool InterleavedAccessImpl::lowerInterleaveIntrinsic(
757757

758758
// We now have a target-specific store, so delete the old one.
759759
DeadInsts.insert(cast<Instruction>(StoredBy));
760-
DeadInsts.insert(InterleaveDeadInsts.begin(), InterleaveDeadInsts.end());
760+
DeadInsts.insert_range(InterleaveDeadInsts);
761761
return true;
762762
}
763763

llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,7 @@ class TransferTracker {
918918

919919
// Move set of active variables from one location to another.
920920
auto MovingVars = ActiveMLocs[Src];
921-
ActiveMLocs[Dst].insert(MovingVars.begin(), MovingVars.end());
921+
ActiveMLocs[Dst].insert_range(MovingVars);
922922
VarLocs[Dst.asU64()] = VarLocs[Src.asU64()];
923923

924924
// For each variable based on Src; create a location at Dst.
@@ -2581,7 +2581,7 @@ void InstrRefBasedLDV::placeMLocPHIs(
25812581
continue;
25822582
}
25832583

2584-
RegUnitsToPHIUp.insert(FoundRegUnits.begin(), FoundRegUnits.end());
2584+
RegUnitsToPHIUp.insert_range(FoundRegUnits);
25852585
}
25862586

25872587
// Lambda to fetch PHIs for a given location, and write into the PHIBlocks
@@ -3087,7 +3087,7 @@ void InstrRefBasedLDV::getBlocksForScope(
30873087
// VarLoc LiveDebugValues tracks variable locations that are defined in
30883088
// blocks not in scope. This is something we could legitimately ignore, but
30893089
// lets allow it for now for the sake of coverage.
3090-
BlocksToExplore.insert(AssignBlocks.begin(), AssignBlocks.end());
3090+
BlocksToExplore.insert_range(AssignBlocks);
30913091

30923092
// Storage for artificial blocks we intend to add to BlocksToExplore.
30933093
DenseSet<const MachineBasicBlock *> ToAdd;
@@ -3137,7 +3137,7 @@ void InstrRefBasedLDV::getBlocksForScope(
31373137
}
31383138
};
31393139

3140-
BlocksToExplore.insert(ToAdd.begin(), ToAdd.end());
3140+
BlocksToExplore.insert_range(ToAdd);
31413141
}
31423142

31433143
void InstrRefBasedLDV::buildVLocValueMap(

llvm/lib/CodeGen/MachineCopyPropagation.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,8 @@ class CopyTracker {
173173

174174
auto Dest = TRI.regunits(CopyOperands->Destination->getReg().asMCReg());
175175
auto Src = TRI.regunits(CopyOperands->Source->getReg().asMCReg());
176-
RegUnitsToInvalidate.insert(Dest.begin(), Dest.end());
177-
RegUnitsToInvalidate.insert(Src.begin(), Src.end());
176+
RegUnitsToInvalidate.insert_range(Dest);
177+
RegUnitsToInvalidate.insert_range(Src);
178178
};
179179

180180
for (MCRegUnit Unit : TRI.regunits(Reg)) {

0 commit comments

Comments
 (0)