Author: Kazu Hirata Date: 2021-01-16T09:40:53-08:00 New Revision: 19aacdb715aea1de56a47b807a555335610a11c2
URL: https://github.com/llvm/llvm-project/commit/19aacdb715aea1de56a47b807a555335610a11c2 DIFF: https://github.com/llvm/llvm-project/commit/19aacdb715aea1de56a47b807a555335610a11c2.diff LOG: [llvm] Construct SmallVector with iterator ranges (NFC) Added: Modified: llvm/include/llvm/Support/GenericDomTree.h llvm/lib/Analysis/ScalarEvolution.cpp llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp llvm/lib/IR/LLVMContextImpl.cpp llvm/lib/Target/AMDGPU/AMDGPUAlwaysInlinePass.cpp llvm/lib/Target/NVPTX/NVPTXISelDAGToDAG.cpp llvm/lib/Transforms/IPO/ArgumentPromotion.cpp llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp llvm/lib/Transforms/Utils/CallPromotionUtils.cpp llvm/lib/Transforms/Utils/Debugify.cpp llvm/lib/Transforms/Utils/LCSSA.cpp llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp llvm/lib/Transforms/Vectorize/VPlan.cpp Removed: ################################################################################ diff --git a/llvm/include/llvm/Support/GenericDomTree.h b/llvm/include/llvm/Support/GenericDomTree.h index 28b2537bc481..18e08dbcd175 100644 --- a/llvm/include/llvm/Support/GenericDomTree.h +++ b/llvm/include/llvm/Support/GenericDomTree.h @@ -839,9 +839,7 @@ class DominatorTreeBase { "NewBB should have a single successor!"); NodeRef NewBBSucc = *GraphT::child_begin(NewBB); - SmallVector<NodeRef, 4> PredBlocks; - for (auto Pred : children<Inverse<N>>(NewBB)) - PredBlocks.push_back(Pred); + SmallVector<NodeRef, 4> PredBlocks(children<Inverse<N>>(NewBB)); assert(!PredBlocks.empty() && "No predblocks?"); diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index 8ec23559cc59..2f5c91aafd39 100644 --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -3274,8 +3274,7 @@ const SCEV *ScalarEvolution::getUDivExactExpr(const SCEV *LHS, // first element of the mulexpr. if (const auto *LHSCst = dyn_cast<SCEVConstant>(Mul->getOperand(0))) { if (LHSCst == RHSCst) { - SmallVector<const SCEV *, 2> Operands; - Operands.append(Mul->op_begin() + 1, Mul->op_end()); + SmallVector<const SCEV *, 2> Operands(drop_begin(Mul->operands(), 1)); return getMulExpr(Operands); } diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp index 2ef3d9947169..ee781d4aa1dd 100644 --- a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp @@ -2194,7 +2194,7 @@ void SelectionDAGLegalize::ExpandFPLibCall(SDNode* Node, if (Node->isStrictFPOpcode()) { EVT RetVT = Node->getValueType(0); - SmallVector<SDValue, 4> Ops(Node->op_begin() + 1, Node->op_end()); + SmallVector<SDValue, 4> Ops(drop_begin(Node->ops(), 1)); TargetLowering::MakeLibCallOptions CallOptions; // FIXME: This doesn't support tail calls. std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(DAG, LC, RetVT, diff --git a/llvm/lib/IR/LLVMContextImpl.cpp b/llvm/lib/IR/LLVMContextImpl.cpp index d96376356fcf..e998138ec3cb 100644 --- a/llvm/lib/IR/LLVMContextImpl.cpp +++ b/llvm/lib/IR/LLVMContextImpl.cpp @@ -176,7 +176,7 @@ unsigned MDNodeOpsKey::calculateHash(MDNode *N, unsigned Offset) { unsigned Hash = hash_combine_range(N->op_begin() + Offset, N->op_end()); #ifndef NDEBUG { - SmallVector<Metadata *, 8> MDs(N->op_begin() + Offset, N->op_end()); + SmallVector<Metadata *, 8> MDs(drop_begin(N->operands(), Offset)); unsigned RawHash = calculateHash(MDs); assert(Hash == RawHash && "Expected hash of MDOperand to equal hash of Metadata*"); diff --git a/llvm/lib/Target/AMDGPU/AMDGPUAlwaysInlinePass.cpp b/llvm/lib/Target/AMDGPU/AMDGPUAlwaysInlinePass.cpp index 3fc57d69b8e8..4fca8bec7423 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPUAlwaysInlinePass.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPUAlwaysInlinePass.cpp @@ -54,13 +54,10 @@ char AMDGPUAlwaysInline::ID = 0; static void recursivelyVisitUsers(GlobalValue &GV, SmallPtrSetImpl<Function *> &FuncsToAlwaysInline) { - SmallVector<User *, 16> Stack; + SmallVector<User *, 16> Stack(GV.users()); SmallPtrSet<const Value *, 8> Visited; - for (User *U : GV.users()) - Stack.push_back(U); - while (!Stack.empty()) { User *U = Stack.pop_back_val(); if (!Visited.insert(U).second) diff --git a/llvm/lib/Target/NVPTX/NVPTXISelDAGToDAG.cpp b/llvm/lib/Target/NVPTX/NVPTXISelDAGToDAG.cpp index 2b2142cc6c21..e1ab64c8c37b 100644 --- a/llvm/lib/Target/NVPTX/NVPTXISelDAGToDAG.cpp +++ b/llvm/lib/Target/NVPTX/NVPTXISelDAGToDAG.cpp @@ -2854,7 +2854,7 @@ bool NVPTXDAGToDAGISel::tryTextureIntrinsic(SDNode *N) { } // Copy over operands - SmallVector<SDValue, 8> Ops(N->op_begin() + 1, N->op_end()); + SmallVector<SDValue, 8> Ops(drop_begin(N->ops(), 1)); Ops.push_back(N->getOperand(0)); // Move chain to the back. ReplaceNode(N, CurDAG->getMachineNode(Opc, SDLoc(N), N->getVTList(), Ops)); @@ -3363,7 +3363,7 @@ bool NVPTXDAGToDAGISel::trySurfaceIntrinsic(SDNode *N) { } // Copy over operands - SmallVector<SDValue, 8> Ops(N->op_begin() + 1, N->op_end()); + SmallVector<SDValue, 8> Ops(drop_begin(N->ops(), 1)); Ops.push_back(N->getOperand(0)); // Move chain to the back. ReplaceNode(N, CurDAG->getMachineNode(Opc, SDLoc(N), N->getVTList(), Ops)); diff --git a/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp b/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp index f6b8c3e44456..877515910dcf 100644 --- a/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp +++ b/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp @@ -822,8 +822,7 @@ static bool canPaddingBeAccessed(Argument *arg) { // Scan through the uses recursively to make sure the pointer is always used // sanely. - SmallVector<Value *, 16> WorkList; - WorkList.insert(WorkList.end(), arg->user_begin(), arg->user_end()); + SmallVector<Value *, 16> WorkList(arg->users()); while (!WorkList.empty()) { Value *V = WorkList.back(); WorkList.pop_back(); diff --git a/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp b/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp index 6a95ec3a6576..b7830555bf73 100644 --- a/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp +++ b/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp @@ -1487,9 +1487,7 @@ makeStatepointExplicitImpl(CallBase *Call, /* to replace */ uint32_t NumPatchBytes = 0; uint32_t Flags = uint32_t(StatepointFlags::None); - SmallVector<Value *, 8> CallArgs; - for (Value *Arg : Call->args()) - CallArgs.push_back(Arg); + SmallVector<Value *, 8> CallArgs(Call->args()); Optional<ArrayRef<Use>> DeoptArgs; if (auto Bundle = Call->getOperandBundle(LLVMContext::OB_deopt)) DeoptArgs = Bundle->Inputs; diff --git a/llvm/lib/Transforms/Utils/CallPromotionUtils.cpp b/llvm/lib/Transforms/Utils/CallPromotionUtils.cpp index 7141e4b1e879..f9207df24d11 100644 --- a/llvm/lib/Transforms/Utils/CallPromotionUtils.cpp +++ b/llvm/lib/Transforms/Utils/CallPromotionUtils.cpp @@ -165,9 +165,7 @@ static void createRetBitCast(CallBase &CB, Type *RetTy, CastInst **RetBitCast) { // Save the users of the calling instruction. These uses will be changed to // use the bitcast after we create it. - SmallVector<User *, 16> UsersToUpdate; - for (User *U : CB.users()) - UsersToUpdate.push_back(U); + SmallVector<User *, 16> UsersToUpdate(CB.users()); // Determine an appropriate location to create the bitcast for the return // value. The location depends on if we have a call or invoke instruction. diff --git a/llvm/lib/Transforms/Utils/Debugify.cpp b/llvm/lib/Transforms/Utils/Debugify.cpp index cb6985f4ca28..3e4d53c10dc9 100644 --- a/llvm/lib/Transforms/Utils/Debugify.cpp +++ b/llvm/lib/Transforms/Utils/Debugify.cpp @@ -239,9 +239,7 @@ bool llvm::stripDebugifyMetadata(Module &M) { NamedMDNode *NMD = M.getModuleFlagsMetadata(); if (!NMD) return Changed; - SmallVector<MDNode *, 4> Flags; - for (MDNode *Flag : NMD->operands()) - Flags.push_back(Flag); + SmallVector<MDNode *, 4> Flags(NMD->operands()); NMD->clearOperands(); for (MDNode *Flag : Flags) { MDString *Key = dyn_cast_or_null<MDString>(Flag->getOperand(1)); diff --git a/llvm/lib/Transforms/Utils/LCSSA.cpp b/llvm/lib/Transforms/Utils/LCSSA.cpp index a601ec9349e0..7437701f5339 100644 --- a/llvm/lib/Transforms/Utils/LCSSA.cpp +++ b/llvm/lib/Transforms/Utils/LCSSA.cpp @@ -295,12 +295,9 @@ bool llvm::formLCSSAForInstructions(SmallVectorImpl<Instruction *> &Worklist, static void computeBlocksDominatingExits( Loop &L, const DominatorTree &DT, SmallVector<BasicBlock *, 8> &ExitBlocks, SmallSetVector<BasicBlock *, 8> &BlocksDominatingExits) { - SmallVector<BasicBlock *, 8> BBWorklist; - // We start from the exit blocks, as every block trivially dominates itself // (not strictly). - for (BasicBlock *BB : ExitBlocks) - BBWorklist.push_back(BB); + SmallVector<BasicBlock *, 8> BBWorklist(ExitBlocks); while (!BBWorklist.empty()) { BasicBlock *BB = BBWorklist.pop_back_val(); diff --git a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp index a904d2550562..99b28b0a832c 100644 --- a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp @@ -3385,7 +3385,7 @@ Value *FortifiedLibCallSimplifier::optimizeMemCCpyChk(CallInst *CI, Value *FortifiedLibCallSimplifier::optimizeSNPrintfChk(CallInst *CI, IRBuilderBase &B) { if (isFortifiedCallFoldable(CI, 3, 1, None, 2)) { - SmallVector<Value *, 8> VariadicArgs(CI->arg_begin() + 5, CI->arg_end()); + SmallVector<Value *, 8> VariadicArgs(drop_begin(CI->args(), 5)); return emitSNPrintf(CI->getArgOperand(0), CI->getArgOperand(1), CI->getArgOperand(4), VariadicArgs, B, TLI); } @@ -3396,7 +3396,7 @@ Value *FortifiedLibCallSimplifier::optimizeSNPrintfChk(CallInst *CI, Value *FortifiedLibCallSimplifier::optimizeSPrintfChk(CallInst *CI, IRBuilderBase &B) { if (isFortifiedCallFoldable(CI, 2, None, None, 1)) { - SmallVector<Value *, 8> VariadicArgs(CI->arg_begin() + 4, CI->arg_end()); + SmallVector<Value *, 8> VariadicArgs(drop_begin(CI->args(), 4)); return emitSPrintf(CI->getArgOperand(0), CI->getArgOperand(3), VariadicArgs, B, TLI); } diff --git a/llvm/lib/Transforms/Vectorize/VPlan.cpp b/llvm/lib/Transforms/Vectorize/VPlan.cpp index 3c941fe8eda5..120562b6db5f 100644 --- a/llvm/lib/Transforms/Vectorize/VPlan.cpp +++ b/llvm/lib/Transforms/Vectorize/VPlan.cpp @@ -200,10 +200,7 @@ VPBlockBase *VPBlockBase::getEnclosingBlockWithPredecessors() { } void VPBlockBase::deleteCFG(VPBlockBase *Entry) { - SmallVector<VPBlockBase *, 8> Blocks; - - for (VPBlockBase *Block : depth_first(Entry)) - Blocks.push_back(Block); + SmallVector<VPBlockBase *, 8> Blocks(depth_first(Entry)); for (VPBlockBase *Block : Blocks) delete Block; _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits