diff --git a/lib/Transforms/AggressiveInstCombine/TruncInstCombine.cpp b/lib/Transforms/AggressiveInstCombine/TruncInstCombine.cpp index 0bcebc17af8..16b82219e8c 100644 --- a/lib/Transforms/AggressiveInstCombine/TruncInstCombine.cpp +++ b/lib/Transforms/AggressiveInstCombine/TruncInstCombine.cpp @@ -130,8 +130,7 @@ bool TruncInstCombine::buildTruncExpressionDag() { case Instruction::Select: { SmallVector Operands; getRelevantOperands(I, Operands); - for (Value *Operand : Operands) - Worklist.push_back(Operand); + append_range(Worklist, Operands); break; } default: diff --git a/lib/Transforms/IPO/GlobalOpt.cpp b/lib/Transforms/IPO/GlobalOpt.cpp index b0a2194052f..223a05e8ea0 100644 --- a/lib/Transforms/IPO/GlobalOpt.cpp +++ b/lib/Transforms/IPO/GlobalOpt.cpp @@ -1933,8 +1933,7 @@ static void makeAllConstantUsesInstructions(Constant *C) { SmallVector UUsers; for (auto *U : Users) { UUsers.clear(); - for (auto *UU : U->users()) - UUsers.push_back(UU); + append_range(UUsers, U->users()); for (auto *UU : UUsers) { Instruction *UI = cast(UU); Instruction *NewU = U->getAsInstruction(); diff --git a/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp b/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp index 76a88ea6b2e..225b4fe95f6 100644 --- a/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp +++ b/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp @@ -334,8 +334,7 @@ void splitAndWriteThinLTOBitcode( Linkage = CFL_Declaration; Elts.push_back(ConstantAsMetadata::get( llvm::ConstantInt::get(Type::getInt8Ty(Ctx), Linkage))); - for (auto Type : Types) - Elts.push_back(Type); + append_range(Elts, Types); CfiFunctionMDs.push_back(MDTuple::get(Ctx, Elts)); } diff --git a/lib/Transforms/IPO/WholeProgramDevirt.cpp b/lib/Transforms/IPO/WholeProgramDevirt.cpp index dc498719c12..cf1ff405c49 100644 --- a/lib/Transforms/IPO/WholeProgramDevirt.cpp +++ b/lib/Transforms/IPO/WholeProgramDevirt.cpp @@ -1279,8 +1279,7 @@ void DevirtModule::applyICallBranchFunnel(VTableSlotInfo &SlotInfo, // x86_64. std::vector NewArgs; NewArgs.push_back(Int8PtrTy); - for (Type *T : CB.getFunctionType()->params()) - NewArgs.push_back(T); + append_range(NewArgs, CB.getFunctionType()->params()); FunctionType *NewFT = FunctionType::get(CB.getFunctionType()->getReturnType(), NewArgs, CB.getFunctionType()->isVarArg()); diff --git a/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp b/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp index fb4170b511c..c7b5f6f7806 100644 --- a/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp +++ b/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp @@ -753,8 +753,7 @@ static bool isObjectSizeLessThanOrEq(Value *V, uint64_t MaxSize, } if (PHINode *PN = dyn_cast(P)) { - for (Value *IncValue : PN->incoming_values()) - Worklist.push_back(IncValue); + append_range(Worklist, PN->incoming_values()); continue; } diff --git a/lib/Transforms/InstCombine/InstructionCombining.cpp b/lib/Transforms/InstCombine/InstructionCombining.cpp index 4998ba68bc3..570a07ec6a5 100644 --- a/lib/Transforms/InstCombine/InstructionCombining.cpp +++ b/lib/Transforms/InstCombine/InstructionCombining.cpp @@ -3827,8 +3827,7 @@ static bool prepareICWorklistFromFunction(Function &F, const DataLayout &DL, } } - for (BasicBlock *SuccBB : successors(TI)) - Worklist.push_back(SuccBB); + append_range(Worklist, successors(TI)); } while (!Worklist.empty()); // Remove instructions inside unreachable blocks. This prevents the diff --git a/lib/Transforms/Scalar/GVN.cpp b/lib/Transforms/Scalar/GVN.cpp index e9cf97398a8..72248babba7 100644 --- a/lib/Transforms/Scalar/GVN.cpp +++ b/lib/Transforms/Scalar/GVN.cpp @@ -366,9 +366,7 @@ GVN::Expression GVN::ValueTable::createExtractvalueExpr(ExtractValueInst *EI) { OI != OE; ++OI) e.varargs.push_back(lookupOrAdd(*OI)); - for (ExtractValueInst::idx_iterator II = EI->idx_begin(), IE = EI->idx_end(); - II != IE; ++II) - e.varargs.push_back(*II); + append_range(e.varargs, EI->indices()); return e; } diff --git a/lib/Transforms/Scalar/GVNSink.cpp b/lib/Transforms/Scalar/GVNSink.cpp index 1cc10ca4dce..aef927ab655 100644 --- a/lib/Transforms/Scalar/GVNSink.cpp +++ b/lib/Transforms/Scalar/GVNSink.cpp @@ -754,8 +754,7 @@ Optional GVNSink::analyzeInstructionForSinking( Cand.NumMemoryInsts = MemoryInstNum; Cand.NumBlocks = ActivePreds.size(); Cand.NumPHIs = NeededPHIs.size(); - for (auto *C : ActivePreds) - Cand.Blocks.push_back(C); + append_range(Cand.Blocks, ActivePreds); return Cand; } diff --git a/lib/Transforms/Scalar/MemCpyOptimizer.cpp b/lib/Transforms/Scalar/MemCpyOptimizer.cpp index e0d2c1cf8b4..a4e695497f3 100644 --- a/lib/Transforms/Scalar/MemCpyOptimizer.cpp +++ b/lib/Transforms/Scalar/MemCpyOptimizer.cpp @@ -929,16 +929,14 @@ bool MemCpyOptPass::performCallSlotOptzn(Instruction *cpyLoad, User *U = srcUseList.pop_back_val(); if (isa(U) || isa(U)) { - for (User *UU : U->users()) - srcUseList.push_back(UU); + append_range(srcUseList, U->users()); continue; } if (GetElementPtrInst *G = dyn_cast(U)) { if (!G->hasAllZeroIndices()) return false; - for (User *UU : U->users()) - srcUseList.push_back(UU); + append_range(srcUseList, U->users()); continue; } if (const IntrinsicInst *IT = dyn_cast(U)) diff --git a/lib/Transforms/Utils/CloneFunction.cpp b/lib/Transforms/Utils/CloneFunction.cpp index 786287ba980..5193b2da26f 100644 --- a/lib/Transforms/Utils/CloneFunction.cpp +++ b/lib/Transforms/Utils/CloneFunction.cpp @@ -433,9 +433,7 @@ void PruningFunctionCloner::CloneBlock(const BasicBlock *BB, CodeInfo->OperandBundleCallSites.push_back(NewInst); // Recursively clone any reachable successor blocks. - const Instruction *TI = BB->getTerminator(); - for (const BasicBlock *Succ : successors(TI)) - ToClone.push_back(Succ); + append_range(ToClone, successors(BB->getTerminator())); } if (CodeInfo) { diff --git a/lib/Transforms/Utils/FixIrreducible.cpp b/lib/Transforms/Utils/FixIrreducible.cpp index 6e18aab2d5f..32408d0a2bd 100644 --- a/lib/Transforms/Utils/FixIrreducible.cpp +++ b/lib/Transforms/Utils/FixIrreducible.cpp @@ -317,9 +317,7 @@ static bool FixIrreducibleImpl(Function &F, LoopInfo &LI, DominatorTree &DT) { // Any SCCs reduced are now already in the list of top-level loops, so simply // add them all to the worklist. - for (auto L : LI) { - WorkList.push_back(L); - } + append_range(WorkList, LI); while (!WorkList.empty()) { auto L = WorkList.back(); diff --git a/lib/Transforms/Utils/LoopSimplify.cpp b/lib/Transforms/Utils/LoopSimplify.cpp index 6337a01a4d6..2e104334ad9 100644 --- a/lib/Transforms/Utils/LoopSimplify.cpp +++ b/lib/Transforms/Utils/LoopSimplify.cpp @@ -171,9 +171,7 @@ static void addBlockAndPredsToSet(BasicBlock *InputBB, BasicBlock *StopBlock, if (Blocks.insert(BB).second && BB != StopBlock) // If BB is not already processed and it is not a stop block then // insert its predecessor in the work list - for (BasicBlock *WBB : predecessors(BB)) { - Worklist.push_back(WBB); - } + append_range(Worklist, predecessors(BB)); } while (!Worklist.empty()); } diff --git a/lib/Transforms/Utils/SSAUpdater.cpp b/lib/Transforms/Utils/SSAUpdater.cpp index a80d577e29f..c210d1c4607 100644 --- a/lib/Transforms/Utils/SSAUpdater.cpp +++ b/lib/Transforms/Utils/SSAUpdater.cpp @@ -253,12 +253,10 @@ public: // We can get our predecessor info by walking the pred_iterator list, // but it is relatively slow. If we already have PHI nodes in this // block, walk one of them to get the predecessor list instead. - if (PHINode *SomePhi = dyn_cast(BB->begin())) { - Preds->append(SomePhi->block_begin(), SomePhi->block_end()); - } else { - for (pred_iterator PI = pred_begin(BB), E = pred_end(BB); PI != E; ++PI) - Preds->push_back(*PI); - } + if (PHINode *SomePhi = dyn_cast(BB->begin())) + append_range(*Preds, SomePhi->blocks()); + else + append_range(*Preds, predecessors(BB)); } /// GetUndefVal - Get an undefined value of the same type as the value diff --git a/lib/Transforms/Vectorize/LoopVectorize.cpp b/lib/Transforms/Vectorize/LoopVectorize.cpp index 865881bb429..da7d7616f6b 100644 --- a/lib/Transforms/Vectorize/LoopVectorize.cpp +++ b/lib/Transforms/Vectorize/LoopVectorize.cpp @@ -7009,8 +7009,7 @@ void LoopVectorizationCostModel::setCostBasedWideningDecision(ElementCount VF) { // Add all instructions used to generate the addresses. SmallVector Worklist; - for (auto *I : AddrDefs) - Worklist.push_back(I); + append_range(Worklist, AddrDefs); while (!Worklist.empty()) { Instruction *I = Worklist.pop_back_val(); for (auto &Op : I->operands())