diff options
author | Kazu Hirata <kazu@google.com> | 2025-03-20 22:24:06 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-20 22:24:06 -0700 |
commit | 599005686a1c27ffe97bb4eb07fcd98359a2af99 (patch) | |
tree | 044944abd13d5134772d7507fef23ac7a6a52a21 /llvm/lib/CodeGen | |
parent | 13bb2f450ef9f64f393fe5527e5ac68362af8ccd (diff) | |
download | llvm-599005686a1c27ffe97bb4eb07fcd98359a2af99.zip llvm-599005686a1c27ffe97bb4eb07fcd98359a2af99.tar.gz llvm-599005686a1c27ffe97bb4eb07fcd98359a2af99.tar.bz2 |
[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.
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 6 | ||||
-rw-r--r-- | llvm/lib/CodeGen/CodeGenPrepare.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/CodeGen/InlineSpiller.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/CodeGen/InterleavedAccessPass.cpp | 6 | ||||
-rw-r--r-- | llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp | 8 | ||||
-rw-r--r-- | llvm/lib/CodeGen/MachineCopyPropagation.cpp | 4 | ||||
-rw-r--r-- | llvm/lib/CodeGen/MachinePipeliner.cpp | 10 | ||||
-rw-r--r-- | llvm/lib/CodeGen/MachineVerifier.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/CodeGen/RDFGraph.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/CodeGen/RDFLiveness.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/CodeGen/TailDuplicator.cpp | 2 |
12 files changed, 23 insertions, 25 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp index dad14b9..3939dae 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp @@ -1170,7 +1170,7 @@ DIE *DwarfCompileUnit::createAndAddScopeChildren(LexicalScope *Scope, // should be emitted for subprograms in this CU. if (!includeMinimalInlineScopes() && !Scope->getInlinedAt()) { auto &LocalDecls = DD->getLocalDeclsForScope(Scope->getScopeNode()); - DeferredLocalDecls.insert(LocalDecls.begin(), LocalDecls.end()); + DeferredLocalDecls.insert_range(LocalDecls); } // Emit inner lexical scopes. diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index b7b0830..a78f606 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -706,8 +706,7 @@ static void interpretValues(const MachineInstr *CurMI, getForwardingRegsDefinedByMI(*CurMI, FwdRegDefs); if (FwdRegDefs.empty()) { // Any definitions by this instruction will clobber earlier reg movements. - ClobberedRegUnits.insert(NewClobberedRegUnits.begin(), - NewClobberedRegUnits.end()); + ClobberedRegUnits.insert_range(NewClobberedRegUnits); return; } @@ -756,8 +755,7 @@ static void interpretValues(const MachineInstr *CurMI, ForwardedRegWorklist.erase(ParamFwdReg); // Any definitions by this instruction will clobber earlier reg movements. - ClobberedRegUnits.insert(NewClobberedRegUnits.begin(), - NewClobberedRegUnits.end()); + ClobberedRegUnits.insert_range(NewClobberedRegUnits); // Now that we are done handling this instruction, add items from the // temporary worklist to the real one. diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp index d5fbd4c..1a791f0 100644 --- a/llvm/lib/CodeGen/CodeGenPrepare.cpp +++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp @@ -7577,7 +7577,7 @@ bool CodeGenPrepare::optimizeSelectInst(SelectInst *SI) { FalseBlock = StartBlock; SmallPtrSet<const Instruction *, 2> INS; - INS.insert(ASI.begin(), ASI.end()); + INS.insert_range(ASI); // Use reverse iterator because later select may use the value of the // earlier select, and we need to propagate value through earlier select // to get the PHI operand. diff --git a/llvm/lib/CodeGen/InlineSpiller.cpp b/llvm/lib/CodeGen/InlineSpiller.cpp index ec71d50..920873c 100644 --- a/llvm/lib/CodeGen/InlineSpiller.cpp +++ b/llvm/lib/CodeGen/InlineSpiller.cpp @@ -1461,7 +1461,7 @@ void HoistSpillHelper::getVisitOrders( // with BBs containing hoisted spills which will be inserted to // SpillsToKeep later during hoisting. SpillsToKeep[MDT[Block]] = Register(); - WorkSet.insert(NodesOnPath.begin(), NodesOnPath.end()); + WorkSet.insert_range(NodesOnPath); } NodesOnPath.clear(); } diff --git a/llvm/lib/CodeGen/InterleavedAccessPass.cpp b/llvm/lib/CodeGen/InterleavedAccessPass.cpp index 3261f28..9e47510 100644 --- a/llvm/lib/CodeGen/InterleavedAccessPass.cpp +++ b/llvm/lib/CodeGen/InterleavedAccessPass.cpp @@ -349,7 +349,7 @@ bool InterleavedAccessImpl::lowerInterleavedLoad( return !Extracts.empty() || BinOpShuffleChanged; } - DeadInsts.insert(Shuffles.begin(), Shuffles.end()); + DeadInsts.insert_range(Shuffles); DeadInsts.insert(LI); return true; @@ -703,7 +703,7 @@ bool InterleavedAccessImpl::lowerDeinterleaveIntrinsic( return false; } - DeadInsts.insert(DeinterleaveDeadInsts.begin(), DeinterleaveDeadInsts.end()); + DeadInsts.insert_range(DeinterleaveDeadInsts); // We now have a target-specific load, so delete the old one. DeadInsts.insert(cast<Instruction>(LoadedVal)); return true; @@ -757,7 +757,7 @@ bool InterleavedAccessImpl::lowerInterleaveIntrinsic( // We now have a target-specific store, so delete the old one. DeadInsts.insert(cast<Instruction>(StoredBy)); - DeadInsts.insert(InterleaveDeadInsts.begin(), InterleaveDeadInsts.end()); + DeadInsts.insert_range(InterleaveDeadInsts); return true; } diff --git a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp index b9da975..fb688a2 100644 --- a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp +++ b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp @@ -918,7 +918,7 @@ public: // Move set of active variables from one location to another. auto MovingVars = ActiveMLocs[Src]; - ActiveMLocs[Dst].insert(MovingVars.begin(), MovingVars.end()); + ActiveMLocs[Dst].insert_range(MovingVars); VarLocs[Dst.asU64()] = VarLocs[Src.asU64()]; // For each variable based on Src; create a location at Dst. @@ -2581,7 +2581,7 @@ void InstrRefBasedLDV::placeMLocPHIs( continue; } - RegUnitsToPHIUp.insert(FoundRegUnits.begin(), FoundRegUnits.end()); + RegUnitsToPHIUp.insert_range(FoundRegUnits); } // Lambda to fetch PHIs for a given location, and write into the PHIBlocks @@ -3087,7 +3087,7 @@ void InstrRefBasedLDV::getBlocksForScope( // VarLoc LiveDebugValues tracks variable locations that are defined in // blocks not in scope. This is something we could legitimately ignore, but // lets allow it for now for the sake of coverage. - BlocksToExplore.insert(AssignBlocks.begin(), AssignBlocks.end()); + BlocksToExplore.insert_range(AssignBlocks); // Storage for artificial blocks we intend to add to BlocksToExplore. DenseSet<const MachineBasicBlock *> ToAdd; @@ -3137,7 +3137,7 @@ void InstrRefBasedLDV::getBlocksForScope( } }; - BlocksToExplore.insert(ToAdd.begin(), ToAdd.end()); + BlocksToExplore.insert_range(ToAdd); } void InstrRefBasedLDV::buildVLocValueMap( diff --git a/llvm/lib/CodeGen/MachineCopyPropagation.cpp b/llvm/lib/CodeGen/MachineCopyPropagation.cpp index 5102639..ff75b87 100644 --- a/llvm/lib/CodeGen/MachineCopyPropagation.cpp +++ b/llvm/lib/CodeGen/MachineCopyPropagation.cpp @@ -173,8 +173,8 @@ public: auto Dest = TRI.regunits(CopyOperands->Destination->getReg().asMCReg()); auto Src = TRI.regunits(CopyOperands->Source->getReg().asMCReg()); - RegUnitsToInvalidate.insert(Dest.begin(), Dest.end()); - RegUnitsToInvalidate.insert(Src.begin(), Src.end()); + RegUnitsToInvalidate.insert_range(Dest); + RegUnitsToInvalidate.insert_range(Src); }; for (MCRegUnit Unit : TRI.regunits(Reg)) { diff --git a/llvm/lib/CodeGen/MachinePipeliner.cpp b/llvm/lib/CodeGen/MachinePipeliner.cpp index 19e8b44..9bd07da 100644 --- a/llvm/lib/CodeGen/MachinePipeliner.cpp +++ b/llvm/lib/CodeGen/MachinePipeliner.cpp @@ -2132,7 +2132,7 @@ void SwingSchedulerDAG::groupRemainingNodes(NodeSetType &NodeSets) { if (!Path.empty()) I.insert(Path.begin(), Path.end()); } - NodesAdded.insert(I.begin(), I.end()); + NodesAdded.insert_range(I); } // Create a new node set with the connected nodes of any successor of a node @@ -2246,12 +2246,12 @@ void SwingSchedulerDAG::computeNodeOrder(NodeSetType &NodeSets) { OrderKind Order; SmallSetVector<SUnit *, 8> N; if (pred_L(NodeOrder, N, DDG.get()) && llvm::set_is_subset(N, Nodes)) { - R.insert(N.begin(), N.end()); + R.insert_range(N); Order = BottomUp; LLVM_DEBUG(dbgs() << " Bottom up (preds) "); } else if (succ_L(NodeOrder, N, DDG.get()) && llvm::set_is_subset(N, Nodes)) { - R.insert(N.begin(), N.end()); + R.insert_range(N); Order = TopDown; LLVM_DEBUG(dbgs() << " Top down (succs) "); } else if (isIntersect(N, Nodes, R)) { @@ -2330,7 +2330,7 @@ void SwingSchedulerDAG::computeNodeOrder(NodeSetType &NodeSets) { LLVM_DEBUG(dbgs() << "\n Switching order to bottom up "); SmallSetVector<SUnit *, 8> N; if (pred_L(NodeOrder, N, DDG.get(), &Nodes)) - R.insert(N.begin(), N.end()); + R.insert_range(N); } else { // Choose the node with the maximum depth. If more than one, choose // the node with the maximum ZeroLatencyDepth. If still more than one, @@ -2385,7 +2385,7 @@ void SwingSchedulerDAG::computeNodeOrder(NodeSetType &NodeSets) { LLVM_DEBUG(dbgs() << "\n Switching order to top down "); SmallSetVector<SUnit *, 8> N; if (succ_L(NodeOrder, N, DDG.get(), &Nodes)) - R.insert(N.begin(), N.end()); + R.insert_range(N); } } LLVM_DEBUG(dbgs() << "\nDone with Nodeset\n"); diff --git a/llvm/lib/CodeGen/MachineVerifier.cpp b/llvm/lib/CodeGen/MachineVerifier.cpp index 735e1f5..754c265 100644 --- a/llvm/lib/CodeGen/MachineVerifier.cpp +++ b/llvm/lib/CodeGen/MachineVerifier.cpp @@ -3286,7 +3286,7 @@ void MachineVerifier::calcRegsPassed() { VRegs.add(PredInfo.vregsPassed); } Info.vregsPassed.reserve(VRegs.size()); - Info.vregsPassed.insert(VRegs.begin(), VRegs.end()); + Info.vregsPassed.insert_range(VRegs); } } diff --git a/llvm/lib/CodeGen/RDFGraph.cpp b/llvm/lib/CodeGen/RDFGraph.cpp index 805b0ee..6d836af 100644 --- a/llvm/lib/CodeGen/RDFGraph.cpp +++ b/llvm/lib/CodeGen/RDFGraph.cpp @@ -1419,7 +1419,7 @@ void DataFlowGraph::recordDefsForDF(BlockRefsMap &PhiM, for (unsigned i = 0; i < IDF.size(); ++i) { auto F = MDF.find(IDF[i]); if (F != MDF.end()) - IDF.insert(F->second.begin(), F->second.end()); + IDF.insert_range(F->second); } // Finally, add the set of defs to each block in the iterated dominance diff --git a/llvm/lib/CodeGen/RDFLiveness.cpp b/llvm/lib/CodeGen/RDFLiveness.cpp index e4e21bb..3502e4b 100644 --- a/llvm/lib/CodeGen/RDFLiveness.cpp +++ b/llvm/lib/CodeGen/RDFLiveness.cpp @@ -763,7 +763,7 @@ void Liveness::computeLiveIns() { for (unsigned i = 0; i < IDFB.size(); ++i) { auto F2 = MDF.find(IDFB[i]); if (F2 != MDF.end()) - IDFB.insert(F2->second.begin(), F2->second.end()); + IDFB.insert_range(F2->second); } // Add B to the IDF(B). This will put B in the IIDF(B). IDFB.insert(&B); diff --git a/llvm/lib/CodeGen/TailDuplicator.cpp b/llvm/lib/CodeGen/TailDuplicator.cpp index e08c8b7..4a2d135 100644 --- a/llvm/lib/CodeGen/TailDuplicator.cpp +++ b/llvm/lib/CodeGen/TailDuplicator.cpp @@ -876,7 +876,7 @@ bool TailDuplicator::tailDuplicate(bool IsSimple, MachineBasicBlock *TailBB, bool Changed = false; SmallSetVector<MachineBasicBlock *, 8> Preds; if (CandidatePtr) - Preds.insert(CandidatePtr->begin(), CandidatePtr->end()); + Preds.insert_range(*CandidatePtr); else Preds.insert(TailBB->pred_begin(), TailBB->pred_end()); |