diff --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp index c29a5e53b82ea..9ab0ff58bb5ba 100644 --- a/llvm/lib/Transforms/IPO/Attributor.cpp +++ b/llvm/lib/Transforms/IPO/Attributor.cpp @@ -583,9 +583,9 @@ static bool getPotentialCopiesOfMemoryValue( UsedAssumedInformation = true; A.recordDependence(*PI, QueryingAA, DepClassTy::OPTIONAL); } - PotentialCopies.insert(NewCopies.begin(), NewCopies.end()); + PotentialCopies.insert_range(NewCopies); if (PotentialValueOrigins) - PotentialValueOrigins->insert(NewCopyOrigins.begin(), NewCopyOrigins.end()); + PotentialValueOrigins->insert_range(NewCopyOrigins); return true; } @@ -2123,7 +2123,7 @@ void Attributor::runTillFixpoint() { SmallVector ChangedAAs; SetVector Worklist, InvalidAAs; - Worklist.insert(DG.SyntheticRoot.begin(), DG.SyntheticRoot.end()); + Worklist.insert_range(DG.SyntheticRoot); do { // Remember the size to determine new attributes. @@ -2200,9 +2200,8 @@ void Attributor::runTillFixpoint() { // Reset the work list and repopulate with the changed abstract attributes. // Note that dependent ones are added above. Worklist.clear(); - Worklist.insert(ChangedAAs.begin(), ChangedAAs.end()); - Worklist.insert(QueryAAsAwaitingUpdate.begin(), - QueryAAsAwaitingUpdate.end()); + Worklist.insert_range(ChangedAAs); + Worklist.insert_range(QueryAAsAwaitingUpdate); QueryAAsAwaitingUpdate.clear(); } while (!Worklist.empty() && (IterationCounter++ < MaxIterations)); diff --git a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp index 4b7902ff502d3..cb794adaba79a 100644 --- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp +++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp @@ -3735,7 +3735,7 @@ struct AAIntraFnReachabilityFunction final } } - DeadEdges.insert(LocalDeadEdges.begin(), LocalDeadEdges.end()); + DeadEdges.insert_range(LocalDeadEdges); return rememberResult(A, RQITy::Reachable::No, RQI, UsedExclusionSet, IsTemporaryRQI); } @@ -12221,8 +12221,7 @@ struct AAIndirectCallInfoCallSite : public AAIndirectCallInfo { } else if (A.isClosedWorldModule()) { ArrayRef IndirectlyCallableFunctions = A.getInfoCache().getIndirectlyCallableFunctions(A); - PotentialCallees.insert(IndirectlyCallableFunctions.begin(), - IndirectlyCallableFunctions.end()); + PotentialCallees.insert_range(IndirectlyCallableFunctions); } if (PotentialCallees.empty()) diff --git a/llvm/lib/Transforms/IPO/FunctionImport.cpp b/llvm/lib/Transforms/IPO/FunctionImport.cpp index 29a1283d9ab21..4a36f49bcbf4b 100644 --- a/llvm/lib/Transforms/IPO/FunctionImport.cpp +++ b/llvm/lib/Transforms/IPO/FunctionImport.cpp @@ -1239,7 +1239,7 @@ void llvm::ComputeCrossModuleImport( else ++EI; } - ELI.second.insert(NewExports.begin(), NewExports.end()); + ELI.second.insert_range(NewExports); } assert(checkVariableImport(Index, ImportLists, ExportLists)); diff --git a/llvm/lib/Transforms/IPO/GlobalDCE.cpp b/llvm/lib/Transforms/IPO/GlobalDCE.cpp index 250c0443cb4af..45fb1f5212b70 100644 --- a/llvm/lib/Transforms/IPO/GlobalDCE.cpp +++ b/llvm/lib/Transforms/IPO/GlobalDCE.cpp @@ -73,7 +73,7 @@ void GlobalDCEPass::ComputeDependencies(Value *V, for (User *CEUser : CE->users()) ComputeDependencies(CEUser, LocalDeps); } - Deps.insert(LocalDeps.begin(), LocalDeps.end()); + Deps.insert_range(LocalDeps); } } diff --git a/llvm/lib/Transforms/IPO/HotColdSplitting.cpp b/llvm/lib/Transforms/IPO/HotColdSplitting.cpp index 4ac004b51dd42..4b3f0e23903aa 100644 --- a/llvm/lib/Transforms/IPO/HotColdSplitting.cpp +++ b/llvm/lib/Transforms/IPO/HotColdSplitting.cpp @@ -733,7 +733,7 @@ bool HotColdSplitting::outlineColdRegions(Function &F, bool HasProfileSummary) { none_of(SubRegion, [&](BasicBlock *Block) { return ColdBlocks.contains(Block); })) { - ColdBlocks.insert(SubRegion.begin(), SubRegion.end()); + ColdBlocks.insert_range(SubRegion); LLVM_DEBUG({ for (auto *Block : SubRegion) diff --git a/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp b/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp index dee2a1b676cd8..f5ae204426170 100644 --- a/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp +++ b/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp @@ -360,8 +360,7 @@ class CallsiteContextGraph { ? CallerEdges : std::vector>()); for (const auto &Edge : Edges) - ContextIds.insert(Edge->getContextIds().begin(), - Edge->getContextIds().end()); + ContextIds.insert_range(Edge->getContextIds()); return ContextIds; } @@ -1372,7 +1371,7 @@ void CallsiteContextGraph:: for (auto Id : ContextIds) if (auto NewId = OldToNewContextIds.find(Id); NewId != OldToNewContextIds.end()) - NewIds.insert(NewId->second.begin(), NewId->second.end()); + NewIds.insert_range(NewId->second); return NewIds; }; @@ -1389,7 +1388,7 @@ void CallsiteContextGraph:: // Only need to recursively iterate to NextNode via this caller edge if // it resulted in any added ids to NextNode. if (!NewIdsToAdd.empty()) { - Edge->getContextIds().insert(NewIdsToAdd.begin(), NewIdsToAdd.end()); + Edge->getContextIds().insert_range(NewIdsToAdd); UpdateCallers(NextNode, Visited, UpdateCallers); } } @@ -2534,8 +2533,7 @@ bool CallsiteContextGraph::calleesMatch( // If there is already an edge between these nodes, simply update it and // return. if (CurEdge) { - CurEdge->ContextIds.insert(Edge->ContextIds.begin(), - Edge->ContextIds.end()); + CurEdge->ContextIds.insert_range(Edge->ContextIds); CurEdge->AllocTypes |= Edge->AllocTypes; return; } @@ -3281,8 +3279,7 @@ void CallsiteContextGraph:: if (ExistingEdgeToNewCallee) { // Since we already have an edge to NewCallee, simply move the ids // onto it, and remove the existing Edge. - ExistingEdgeToNewCallee->getContextIds().insert(ContextIdsToMove.begin(), - ContextIdsToMove.end()); + ExistingEdgeToNewCallee->getContextIds().insert_range(ContextIdsToMove); ExistingEdgeToNewCallee->AllocTypes |= Edge->AllocTypes; assert(Edge->ContextIds == ContextIdsToMove); removeEdgeFromGraph(Edge.get()); @@ -3302,8 +3299,7 @@ void CallsiteContextGraph:: if (ExistingEdgeToNewCallee) { // Since we already have an edge to NewCallee, simply move the ids // onto it. - ExistingEdgeToNewCallee->getContextIds().insert(ContextIdsToMove.begin(), - ContextIdsToMove.end()); + ExistingEdgeToNewCallee->getContextIds().insert_range(ContextIdsToMove); ExistingEdgeToNewCallee->AllocTypes |= CallerEdgeAllocType; } else { // Otherwise, create a new edge to NewCallee for the ids being moved. @@ -3350,8 +3346,7 @@ void CallsiteContextGraph:: // removed none type edges after creating the clone. If we can't find // a corresponding edge there, fall through to the cloning below. if (auto *NewCalleeEdge = NewCallee->findEdgeFromCallee(CalleeToUse)) { - NewCalleeEdge->getContextIds().insert(EdgeContextIdsToMove.begin(), - EdgeContextIdsToMove.end()); + NewCalleeEdge->getContextIds().insert_range(EdgeContextIdsToMove); NewCalleeEdge->AllocTypes |= computeAllocType(EdgeContextIdsToMove); continue; } @@ -3402,8 +3397,8 @@ void CallsiteContextGraph:: if (ExistingEdgeToNewCaller) { // Since we already have an edge to NewCaller, simply move the ids // onto it, and remove the existing Edge. - ExistingEdgeToNewCaller->getContextIds().insert( - Edge->getContextIds().begin(), Edge->getContextIds().end()); + ExistingEdgeToNewCaller->getContextIds().insert_range( + Edge->getContextIds()); ExistingEdgeToNewCaller->AllocTypes |= Edge->AllocTypes; Edge->ContextIds.clear(); Edge->AllocTypes = (uint8_t)AllocationType::None; @@ -3465,8 +3460,7 @@ void CallsiteContextGraph:: // edge, this may not hold true when recursive handling enabled. assert(IsNewNode || ExistingCallerEdge || AllowRecursiveCallsites); if (ExistingCallerEdge) { - ExistingCallerEdge->getContextIds().insert(EdgeContextIdsToMove.begin(), - EdgeContextIdsToMove.end()); + ExistingCallerEdge->getContextIds().insert_range(EdgeContextIdsToMove); ExistingCallerEdge->AllocTypes |= computeAllocType(EdgeContextIdsToMove); continue; diff --git a/llvm/lib/Transforms/IPO/MergeFunctions.cpp b/llvm/lib/Transforms/IPO/MergeFunctions.cpp index c463cda68d4b5..924db314674d5 100644 --- a/llvm/lib/Transforms/IPO/MergeFunctions.cpp +++ b/llvm/lib/Transforms/IPO/MergeFunctions.cpp @@ -321,7 +321,7 @@ bool MergeFunctionsPass::runOnModule(Module &M) { SmallVector UsedV; collectUsedGlobalVariables(M, UsedV, /*CompilerUsed=*/false); collectUsedGlobalVariables(M, UsedV, /*CompilerUsed=*/true); - MF.getUsed().insert(UsedV.begin(), UsedV.end()); + MF.getUsed().insert_range(UsedV); return MF.run(M); } diff --git a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp index 95c42f2b9bd45..29bf214a5c9e7 100644 --- a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp +++ b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp @@ -675,7 +675,7 @@ struct BooleanStateWithSetVector : public BooleanState { /// "Clamp" this state with \p RHS. BooleanStateWithSetVector &operator^=(const BooleanStateWithSetVector &RHS) { BooleanState::operator^=(RHS); - Set.insert(RHS.Set.begin(), RHS.Set.end()); + Set.insert_range(RHS.Set); return *this; } diff --git a/llvm/lib/Transforms/IPO/SampleProfileProbe.cpp b/llvm/lib/Transforms/IPO/SampleProfileProbe.cpp index a614e2d169534..e15aa0472088c 100644 --- a/llvm/lib/Transforms/IPO/SampleProfileProbe.cpp +++ b/llvm/lib/Transforms/IPO/SampleProfileProbe.cpp @@ -199,8 +199,7 @@ void SampleProfileProber::computeBlocksToIgnore( computeEHOnlyBlocks(*F, BlocksAndCallsToIgnore); findUnreachableBlocks(BlocksAndCallsToIgnore); - BlocksToIgnore.insert(BlocksAndCallsToIgnore.begin(), - BlocksAndCallsToIgnore.end()); + BlocksToIgnore.insert_range(BlocksAndCallsToIgnore); // Handle the call-to-invoke conversion case: make sure that the probe id and // callsite id are consistent before and after the block split. For block diff --git a/llvm/lib/Transforms/Instrumentation/BlockCoverageInference.cpp b/llvm/lib/Transforms/Instrumentation/BlockCoverageInference.cpp index 0e49984c6ee33..c068d70b3a458 100644 --- a/llvm/lib/Transforms/Instrumentation/BlockCoverageInference.cpp +++ b/llvm/lib/Transforms/Instrumentation/BlockCoverageInference.cpp @@ -239,10 +239,10 @@ void BlockCoverageInference::getReachableAvoiding(const BasicBlock &Start, Visited.insert(&Avoid); if (IsForward) { auto Range = depth_first_ext(&Start, Visited); - Reachable.insert(Range.begin(), Range.end()); + Reachable.insert_range(Range); } else { auto Range = inverse_depth_first_ext(&Start, Visited); - Reachable.insert(Range.begin(), Range.end()); + Reachable.insert_range(Range); } } diff --git a/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp b/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp index 5d5cbf93c870d..0b35ff82478e3 100644 --- a/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp +++ b/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp @@ -562,7 +562,7 @@ checkHoistValue(Value *V, Instruction *InsertPoint, DominatorTree &DT, if (AllOpsHoisted) { CHR_DEBUG(dbgs() << "checkHoistValue " << *I << "\n"); if (HoistStops) - HoistStops->insert(OpsHoistStops.begin(), OpsHoistStops.end()); + HoistStops->insert_range(OpsHoistStops); Visited[I] = true; return true; } @@ -1176,8 +1176,7 @@ SmallVector CHR::splitScope( // point. Union the bases. PrevSplitFromOuter = false; PrevConditionValues = *OuterConditionValues; - PrevConditionValues.insert(ConditionValues.begin(), - ConditionValues.end()); + PrevConditionValues.insert_range(ConditionValues); PrevInsertPoint = OuterInsertPoint; } } else { @@ -1209,7 +1208,7 @@ SmallVector CHR::splitScope( }); } else { // Not splitting. Union the bases. Keep the hoist point. - PrevConditionValues.insert(ConditionValues.begin(), ConditionValues.end()); + PrevConditionValues.insert_range(ConditionValues); } } } diff --git a/llvm/lib/Transforms/Instrumentation/SanitizerBinaryMetadata.cpp b/llvm/lib/Transforms/Instrumentation/SanitizerBinaryMetadata.cpp index 66a9f7c43d3fe..c5932f0d65ee1 100644 --- a/llvm/lib/Transforms/Instrumentation/SanitizerBinaryMetadata.cpp +++ b/llvm/lib/Transforms/Instrumentation/SanitizerBinaryMetadata.cpp @@ -440,7 +440,7 @@ bool SanitizerBinaryMetadata::runOn(Instruction &I, MetadataInfoSet &MIS, // Attach MD_pcsections to instruction. if (!InstMetadata.empty()) { - MIS.insert(InstMetadata.begin(), InstMetadata.end()); + MIS.insert_range(InstMetadata); SmallVector Sections; for (const auto &MI : InstMetadata) Sections.push_back({getSectionName(MI->SectionSuffix), {}}); diff --git a/llvm/lib/Transforms/ObjCARC/PtrState.cpp b/llvm/lib/Transforms/ObjCARC/PtrState.cpp index e9b2dbeb62e60..3af238996fa76 100644 --- a/llvm/lib/Transforms/ObjCARC/PtrState.cpp +++ b/llvm/lib/Transforms/ObjCARC/PtrState.cpp @@ -107,7 +107,7 @@ bool RRInfo::Merge(const RRInfo &Other) { CFGHazardAfflicted |= Other.CFGHazardAfflicted; // Merge the call sets. - Calls.insert(Other.Calls.begin(), Other.Calls.end()); + Calls.insert_range(Other.Calls); // Merge the insert point sets. If there are any differences, // that makes this a partial merge. diff --git a/llvm/lib/Transforms/Scalar/ConstantHoisting.cpp b/llvm/lib/Transforms/Scalar/ConstantHoisting.cpp index 8cc8e713941b1..40c4c15b7120b 100644 --- a/llvm/lib/Transforms/Scalar/ConstantHoisting.cpp +++ b/llvm/lib/Transforms/Scalar/ConstantHoisting.cpp @@ -248,7 +248,7 @@ static void findBestInsertionSet(DominatorTree &DT, BlockFrequencyInfo &BFI, continue; // Add nodes on the Path into Candidates. - Candidates.insert(Path.begin(), Path.end()); + Candidates.insert_range(Path); } // Sort the nodes in Candidates in top-down order and save the nodes @@ -283,7 +283,7 @@ static void findBestInsertionSet(DominatorTree &DT, BlockFrequencyInfo &BFI, (InsertPtsFreq == BFI.getBlockFreq(Node) && InsertPts.size() > 1)) BBs.insert(Entry); else - BBs.insert(InsertPts.begin(), InsertPts.end()); + BBs.insert_range(InsertPts); break; } @@ -304,7 +304,7 @@ static void findBestInsertionSet(DominatorTree &DT, BlockFrequencyInfo &BFI, ParentInsertPts.insert(Node); ParentPtsFreq += BFI.getBlockFreq(Node); } else { - ParentInsertPts.insert(InsertPts.begin(), InsertPts.end()); + ParentInsertPts.insert_range(InsertPts); ParentPtsFreq += InsertPtsFreq; } } diff --git a/llvm/lib/Transforms/Scalar/GVN.cpp b/llvm/lib/Transforms/Scalar/GVN.cpp index 85fcdd95f5d87..b41899a2dff66 100644 --- a/llvm/lib/Transforms/Scalar/GVN.cpp +++ b/llvm/lib/Transforms/Scalar/GVN.cpp @@ -3194,7 +3194,7 @@ void GVNPass::addDeadBlock(BasicBlock *BB) { // All blocks dominated by D are dead. SmallVector Dom; DT->getDescendants(D, Dom); - DeadBlocks.insert(Dom.begin(), Dom.end()); + DeadBlocks.insert_range(Dom); // Figure out the dominance-frontier(D). for (BasicBlock *B : Dom) { diff --git a/llvm/lib/Transforms/Scalar/GVNSink.cpp b/llvm/lib/Transforms/Scalar/GVNSink.cpp index 5b180c2390bfa..5d9a5f90af186 100644 --- a/llvm/lib/Transforms/Scalar/GVNSink.cpp +++ b/llvm/lib/Transforms/Scalar/GVNSink.cpp @@ -663,7 +663,7 @@ GVNSink::analyzeInstructionForSinking(LockstepReverseIterator &LRI, // values. PHIContents.clear(); for (auto &PHI : NeededPHIs) - PHIContents.insert(PHI.getValues().begin(), PHI.getValues().end()); + PHIContents.insert_range(PHI.getValues()); } // Is this instruction required by a later PHI that doesn't match this PHI? @@ -705,7 +705,7 @@ GVNSink::analyzeInstructionForSinking(LockstepReverseIterator &LRI, NeededPHIs.reserve(NeededPHIs.size()); NeededPHIs.insert(PHI); - PHIContents.insert(PHI.getValues().begin(), PHI.getValues().end()); + PHIContents.insert_range(PHI.getValues()); } if (isMemoryInst(NewInsts[0])) diff --git a/llvm/lib/Transforms/Scalar/LoopDistribute.cpp b/llvm/lib/Transforms/Scalar/LoopDistribute.cpp index 92fd269f7557e..efbd1b89aca8f 100644 --- a/llvm/lib/Transforms/Scalar/LoopDistribute.cpp +++ b/llvm/lib/Transforms/Scalar/LoopDistribute.cpp @@ -143,7 +143,7 @@ class InstPartition { /// Moves this partition into \p Other. This partition becomes empty /// after this. void moveTo(InstPartition &Other) { - Other.Set.insert(Set.begin(), Set.end()); + Other.Set.insert_range(Set); Set.clear(); Other.DepCycle |= DepCycle; } diff --git a/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp b/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp index 2462ec33e0c20..8dc7f325f6262 100644 --- a/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp +++ b/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp @@ -719,7 +719,7 @@ bool LoopIdiomRecognize::processLoopStores(SmallVectorImpl &SL, MaybeAlign(HeadStore->getAlign()), StoredVal, HeadStore, AdjacentStores, StoreEv, BECount, IsNegStride)) { - TransformedStores.insert(AdjacentStores.begin(), AdjacentStores.end()); + TransformedStores.insert_range(AdjacentStores); Changed = true; } } diff --git a/llvm/lib/Transforms/Scalar/LoopSink.cpp b/llvm/lib/Transforms/Scalar/LoopSink.cpp index 7f0c974ac4c5a..b9fde4c6a3b76 100644 --- a/llvm/lib/Transforms/Scalar/LoopSink.cpp +++ b/llvm/lib/Transforms/Scalar/LoopSink.cpp @@ -120,7 +120,7 @@ findBBsToSinkInto(const Loop &L, const SmallPtrSetImpl &UseBBs, if (UseBBs.size() == 0) return BBsToSinkInto; - BBsToSinkInto.insert(UseBBs.begin(), UseBBs.end()); + BBsToSinkInto.insert_range(UseBBs); SmallPtrSet BBsDominatedByColdestBB; // For every iteration: diff --git a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp index 2c3d64b0e07d9..ed3709b74d60f 100644 --- a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp +++ b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp @@ -1738,7 +1738,7 @@ bool LSRUse::InsertFormula(const Formula &F, const Loop &L) { Formulae.push_back(F); // Record registers now being used by this use. - Regs.insert(F.BaseRegs.begin(), F.BaseRegs.end()); + Regs.insert_range(F.BaseRegs); if (F.ScaledReg) Regs.insert(F.ScaledReg); @@ -1759,7 +1759,7 @@ void LSRUse::RecomputeRegs(size_t LUIdx, RegUseTracker &RegUses) { Regs.clear(); for (const Formula &F : Formulae) { if (F.ScaledReg) Regs.insert(F.ScaledReg); - Regs.insert(F.BaseRegs.begin(), F.BaseRegs.end()); + Regs.insert_range(F.BaseRegs); } // Update the RegTracker. @@ -3215,8 +3215,7 @@ void LSRInstance::ChainInstruction(Instruction *UserInst, Instruction *IVOper, SmallPtrSet &NearUsers = ChainUsersVec[ChainIdx].NearUsers; // This chain's NearUsers become FarUsers. if (!LastIncExpr->isZero()) { - ChainUsersVec[ChainIdx].FarUsers.insert(NearUsers.begin(), - NearUsers.end()); + ChainUsersVec[ChainIdx].FarUsers.insert_range(NearUsers); NearUsers.clear(); } @@ -5294,7 +5293,7 @@ void LSRInstance::NarrowSearchSpaceByDeletingCostlyFormulas() { Formula &F = LU.Formulae[0]; LLVM_DEBUG(dbgs() << " Leaving only "; F.print(dbgs()); dbgs() << '\n'); // When we choose the formula, the regs become unique. - UniqRegs.insert(F.BaseRegs.begin(), F.BaseRegs.end()); + UniqRegs.insert_range(F.BaseRegs); if (F.ScaledReg) UniqRegs.insert(F.ScaledReg); } diff --git a/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp b/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp index 5f28ee616f0e4..be9b0e3244b65 100644 --- a/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp +++ b/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp @@ -1517,9 +1517,9 @@ PreservedAnalyses LoopFullUnrollPass::run(Loop &L, LoopAnalysisManager &AM, Loop *ParentL = L.getParentLoop(); SmallPtrSet OldLoops; if (ParentL) - OldLoops.insert(ParentL->begin(), ParentL->end()); + OldLoops.insert_range(*ParentL); else - OldLoops.insert(AR.LI.begin(), AR.LI.end()); + OldLoops.insert_range(AR.LI); std::string LoopName = std::string(L.getName()); diff --git a/llvm/lib/Transforms/Scalar/NewGVN.cpp b/llvm/lib/Transforms/Scalar/NewGVN.cpp index 168f1d689d314..44971af5841ea 100644 --- a/llvm/lib/Transforms/Scalar/NewGVN.cpp +++ b/llvm/lib/Transforms/Scalar/NewGVN.cpp @@ -2840,7 +2840,7 @@ NewGVN::makePossiblePHIOfOps(Instruction *I, return nullptr; } - Deps.insert(CurrentDeps.begin(), CurrentDeps.end()); + Deps.insert_range(CurrentDeps); } else { LLVM_DEBUG(dbgs() << "Skipping phi of ops operand for incoming block " << getBlockName(PredBB) diff --git a/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp b/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp index 68c079373e556..364fe5a9fad11 100644 --- a/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp +++ b/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp @@ -3361,7 +3361,7 @@ static void findLiveSetAtInst(Instruction *Inst, GCPtrLivenessData &Data, computeLiveInValues(BB->rbegin(), ++Inst->getIterator().getReverse(), LiveOut, GC); LiveOut.remove(Inst); - Out.insert(LiveOut.begin(), LiveOut.end()); + Out.insert_range(LiveOut); } static void recomputeLiveInValues(GCPtrLivenessData &RevisedLivenessData, diff --git a/llvm/lib/Transforms/Utils/IRNormalizer.cpp b/llvm/lib/Transforms/Utils/IRNormalizer.cpp index d36da331fedf7..7b9f193cbf514 100644 --- a/llvm/lib/Transforms/Utils/IRNormalizer.cpp +++ b/llvm/lib/Transforms/Utils/IRNormalizer.cpp @@ -679,7 +679,7 @@ SetVector IRNormalizer::getOutputFootprint( // Vector for outputs which use UI. SetVector OutputsUsingUI = getOutputFootprint(UI, Visited); // Insert the indexes of outputs using UI. - Outputs.insert(OutputsUsingUI.begin(), OutputsUsingUI.end()); + Outputs.insert_range(OutputsUsingUI); } } } diff --git a/llvm/lib/Transforms/Utils/LoopUnrollAndJam.cpp b/llvm/lib/Transforms/Utils/LoopUnrollAndJam.cpp index 8470f0333d249..d1c7eaf85de7e 100644 --- a/llvm/lib/Transforms/Utils/LoopUnrollAndJam.cpp +++ b/llvm/lib/Transforms/Utils/LoopUnrollAndJam.cpp @@ -580,9 +580,9 @@ llvm::UnrollAndJamLoop(Loop *L, unsigned Count, unsigned TripCount, // Merge adjacent basic blocks, if possible. SmallPtrSet MergeBlocks; - MergeBlocks.insert(ForeBlocksLast.begin(), ForeBlocksLast.end()); - MergeBlocks.insert(SubLoopBlocksLast.begin(), SubLoopBlocksLast.end()); - MergeBlocks.insert(AftBlocksLast.begin(), AftBlocksLast.end()); + MergeBlocks.insert_range(ForeBlocksLast); + MergeBlocks.insert_range(SubLoopBlocksLast); + MergeBlocks.insert_range(AftBlocksLast); MergeBlockSuccessorsIntoGivenBlocks(MergeBlocks, L, &DTU, LI); diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp index 17c5fa6503f20..1e4342c65494d 100644 --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -2444,7 +2444,7 @@ static bool sinkCommonCodeFromPredecessors(BasicBlock *BB, canSinkInstructions(*LRI, PHIOperands)) { LLVM_DEBUG(dbgs() << "SINK: instruction can be sunk: " << *(*LRI)[0] << "\n"); - InstructionsToSink.insert((*LRI).begin(), (*LRI).end()); + InstructionsToSink.insert_range(*LRI); ++ScanIdx; --LRI; } @@ -2514,7 +2514,7 @@ static bool sinkCommonCodeFromPredecessors(BasicBlock *BB, dbgs() << "SINK: stopping here, too many PHIs would be created!\n"); break; } - InstructionsProfitableToSink.insert((*LRI).begin(), (*LRI).end()); + InstructionsProfitableToSink.insert_range(*LRI); --LRI; ++Idx; } diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp index 89337dc385350..562eaa376d51e 100644 --- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp +++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp @@ -3009,7 +3009,7 @@ void InnerLoopVectorizer::sinkScalarOperands(Instruction *PredInst) { do { // Add the instructions that need to be reanalyzed to the worklist, and // reset the changed indicator. - Worklist.insert(InstsToReanalyze.begin(), InstsToReanalyze.end()); + Worklist.insert_range(InstsToReanalyze); InstsToReanalyze.clear(); Changed = false; @@ -3259,7 +3259,7 @@ void LoopVectorizationCostModel::collectLoopScalars(ElementCount VF) { << "\n"); } - Scalars[VF].insert(Worklist.begin(), Worklist.end()); + Scalars[VF].insert_range(Worklist); } bool LoopVectorizationCostModel::isScalarWithPredication( @@ -3750,7 +3750,7 @@ void LoopVectorizationCostModel::collectLoopUniforms(ElementCount VF) { AddToWorklistIfAllowed(IndUpdate); } - Uniforms[VF].insert(Worklist.begin(), Worklist.end()); + Uniforms[VF].insert_range(Worklist); } bool LoopVectorizationCostModel::runtimeChecksRequired() { @@ -7008,14 +7008,14 @@ void LoopVectorizationCostModel::collectValuesToIgnore() { for (const auto &Reduction : Legal->getReductionVars()) { const RecurrenceDescriptor &RedDes = Reduction.second; const SmallPtrSetImpl &Casts = RedDes.getCastInsts(); - VecValuesToIgnore.insert(Casts.begin(), Casts.end()); + VecValuesToIgnore.insert_range(Casts); } // Ignore type-casting instructions we identified during induction // detection. for (const auto &Induction : Legal->getInductionVars()) { const InductionDescriptor &IndDes = Induction.second; const SmallVectorImpl &Casts = IndDes.getCastInsts(); - VecValuesToIgnore.insert(Casts.begin(), Casts.end()); + VecValuesToIgnore.insert_range(Casts); } } diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp index 1d9d80bd69def..5e4e92a5719df 100644 --- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -3811,7 +3811,7 @@ class BoUpSLP { if (AllConstsOrCasts) CastMaxMinBWSizes = std::make_pair(std::numeric_limits::max(), 1); - MustGather.insert(VL.begin(), VL.end()); + MustGather.insert_range(VL); } if (UserTreeIdx.UserTE) @@ -7346,7 +7346,7 @@ static void gatherPossiblyVectorizableLoads( assert(!LocalToAdd.empty() && "Expected some elements to add."); for (unsigned Idx : LocalToAdd) It->emplace_back(Data[Idx].first, Data[Idx].second + Offset); - ToAdd.insert(LocalToAdd.begin(), LocalToAdd.end()); + ToAdd.insert_range(LocalToAdd); It = FindMatchingLoads(Data, GatheredLoads, LocalToAdd, Repeated, Offset, Start); } @@ -7393,8 +7393,7 @@ void BoUpSLP::tryToVectorizeGatheredLoads( SmallVector> LoadSetsToVectorize( LoadEntriesToVectorize.size()); for (auto [Idx, Set] : zip(LoadEntriesToVectorize, LoadSetsToVectorize)) - Set.insert(VectorizableTree[Idx]->Scalars.begin(), - VectorizableTree[Idx]->Scalars.end()); + Set.insert_range(VectorizableTree[Idx]->Scalars); // Sort loads by distance. auto LoadSorter = [](const std::pair &L1, @@ -7518,7 +7517,7 @@ void BoUpSLP::tryToVectorizeGatheredLoads( } if (LS != LoadsState::Gather) { Results.emplace_back(Values, LS); - VectorizedLoads.insert(Slice.begin(), Slice.end()); + VectorizedLoads.insert_range(Slice); // If we vectorized initial block, no need to try to vectorize it // again. if (Cnt == StartIdx) @@ -7546,7 +7545,7 @@ void BoUpSLP::tryToVectorizeGatheredLoads( ArrayRef Values( reinterpret_cast(Slice.begin()), Slice.size()); Results.emplace_back(Values, LoadsState::ScatterVectorize); - VectorizedLoads.insert(Slice.begin(), Slice.end()); + VectorizedLoads.insert_range(Slice); // If we vectorized initial block, no need to try to vectorize it again. if (Cnt == StartIdx) StartIdx += NumElts; @@ -19426,8 +19425,8 @@ void BoUpSLP::computeMinimumValueSizes() { cast(TreeRoot.front()->getType()->getScalarType()) ->getBitWidth()) { if (UserIgnoreList) - AnalyzedMinBWVals.insert(TreeRoot.begin(), TreeRoot.end()); - NodesToKeepBWs.insert(ToDemote.begin(), ToDemote.end()); + AnalyzedMinBWVals.insert_range(TreeRoot); + NodesToKeepBWs.insert_range(ToDemote); continue; } @@ -19849,7 +19848,7 @@ bool SLPVectorizerPass::vectorizeStores( } else if (*Res) { // Mark the vectorized stores so that we don't vectorize them // again. - VectorizedStores.insert(Slice.begin(), Slice.end()); + VectorizedStores.insert_range(Slice); // Mark the vectorized stores so that we don't vectorize them // again. AnyProfitableGraph = RepeatChanged = Changed = true; @@ -21480,7 +21479,7 @@ class HorizontalReduction { #ifndef NDEBUG SmallSet IgnoreSet; for (ArrayRef RdxOps : ReductionOps) - IgnoreSet.insert(RdxOps.begin(), RdxOps.end()); + IgnoreSet.insert_range(RdxOps); #endif for (ArrayRef RdxOps : ReductionOps) { for (Value *Ignore : RdxOps) { @@ -22883,7 +22882,7 @@ bool SLPVectorizerPass::vectorizeChainsInBlock(BasicBlock *BB, BoUpSLP &R) { return !PHI || R.isDeleted(PHI); })) PHIToOpcodes.clear(); - VisitedInstrs.insert(Incoming.begin(), Incoming.end()); + VisitedInstrs.insert_range(Incoming); } while (HaveVectorizedPhiNodes); VisitedInstrs.clear(); diff --git a/llvm/lib/Transforms/Vectorize/VPlan.cpp b/llvm/lib/Transforms/Vectorize/VPlan.cpp index b63cdd04530ab..019abe0579325 100644 --- a/llvm/lib/Transforms/Vectorize/VPlan.cpp +++ b/llvm/lib/Transforms/Vectorize/VPlan.cpp @@ -147,7 +147,7 @@ template static T *getPlanEntry(T *Start) { if (Current->getNumPredecessors() == 0) return Current; auto &Predecessors = Current->getPredecessors(); - WorkList.insert(Predecessors.begin(), Predecessors.end()); + WorkList.insert_range(Predecessors); } llvm_unreachable("VPlan without any entry node without predecessors");