diff options
author | Kazu Hirata <kazu@google.com> | 2021-01-04 11:42:43 -0800 |
---|---|---|
committer | Kazu Hirata <kazu@google.com> | 2021-01-04 11:42:44 -0800 |
commit | 848e8f938fdbefc98a1e079c8a63768cfe9657ab (patch) | |
tree | 3d561053ea739867a3ee82ecb34914c713891e47 | |
parent | b8f22f9d3000b13c63a323bcf5230929191f402a (diff) | |
download | llvm-848e8f938fdbefc98a1e079c8a63768cfe9657ab.zip llvm-848e8f938fdbefc98a1e079c8a63768cfe9657ab.tar.gz llvm-848e8f938fdbefc98a1e079c8a63768cfe9657ab.tar.bz2 |
[llvm] Construct SmallVector with iterator ranges (NFC)
-rw-r--r-- | llvm/include/llvm/Analysis/TargetTransformInfo.h | 3 | ||||
-rw-r--r-- | llvm/include/llvm/Analysis/TargetTransformInfoImpl.h | 3 | ||||
-rw-r--r-- | llvm/include/llvm/IR/DebugInfoMetadata.h | 5 | ||||
-rw-r--r-- | llvm/include/llvm/IR/Metadata.h | 3 | ||||
-rw-r--r-- | llvm/include/llvm/IR/PredIteratorCache.h | 2 | ||||
-rw-r--r-- | llvm/lib/Analysis/InstructionSimplify.cpp | 4 | ||||
-rw-r--r-- | llvm/lib/Analysis/ScalarEvolution.cpp | 16 | ||||
-rw-r--r-- | llvm/lib/IR/Constants.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/IR/Verifier.cpp | 4 | ||||
-rw-r--r-- | llvm/lib/TableGen/Record.cpp | 4 |
10 files changed, 18 insertions, 28 deletions
diff --git a/llvm/include/llvm/Analysis/TargetTransformInfo.h b/llvm/include/llvm/Analysis/TargetTransformInfo.h index d9d0442..ee34312 100644 --- a/llvm/include/llvm/Analysis/TargetTransformInfo.h +++ b/llvm/include/llvm/Analysis/TargetTransformInfo.h @@ -332,8 +332,7 @@ public: /// This is a helper function which calls the two-argument getUserCost /// with \p Operands which are the current operands U has. int getUserCost(const User *U, TargetCostKind CostKind) const { - SmallVector<const Value *, 4> Operands(U->value_op_begin(), - U->value_op_end()); + SmallVector<const Value *, 4> Operands(U->operand_values()); return getUserCost(U, Operands, CostKind); } diff --git a/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h b/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h index ef0653d..47de99b 100644 --- a/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h +++ b/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h @@ -1071,8 +1071,7 @@ public: } int getInstructionLatency(const Instruction *I) { - SmallVector<const Value *, 4> Operands(I->value_op_begin(), - I->value_op_end()); + SmallVector<const Value *, 4> Operands(I->operand_values()); if (getUserCost(I, Operands, TTI::TCK_Latency) == TTI::TCC_Free) return 0; diff --git a/llvm/include/llvm/IR/DebugInfoMetadata.h b/llvm/include/llvm/IR/DebugInfoMetadata.h index 94b3beb..20c212c 100644 --- a/llvm/include/llvm/IR/DebugInfoMetadata.h +++ b/llvm/include/llvm/IR/DebugInfoMetadata.h @@ -240,9 +240,8 @@ class GenericDINode : public DINode { StorageType Storage, bool ShouldCreate = true); TempGenericDINode cloneImpl() const { - return getTemporary( - getContext(), getTag(), getHeader(), - SmallVector<Metadata *, 4>(dwarf_op_begin(), dwarf_op_end())); + return getTemporary(getContext(), getTag(), getHeader(), + SmallVector<Metadata *, 4>(dwarf_operands())); } public: diff --git a/llvm/include/llvm/IR/Metadata.h b/llvm/include/llvm/IR/Metadata.h index edd1d4b..33b92c3 100644 --- a/llvm/include/llvm/IR/Metadata.h +++ b/llvm/include/llvm/IR/Metadata.h @@ -1128,8 +1128,7 @@ class MDTuple : public MDNode { StorageType Storage, bool ShouldCreate = true); TempMDTuple cloneImpl() const { - return getTemporary(getContext(), - SmallVector<Metadata *, 4>(op_begin(), op_end())); + return getTemporary(getContext(), SmallVector<Metadata *, 4>(operands())); } public: diff --git a/llvm/include/llvm/IR/PredIteratorCache.h b/llvm/include/llvm/IR/PredIteratorCache.h index 4d8efcf..6bbd7e5 100644 --- a/llvm/include/llvm/IR/PredIteratorCache.h +++ b/llvm/include/llvm/IR/PredIteratorCache.h @@ -44,7 +44,7 @@ private: if (Entry) return Entry; - SmallVector<BasicBlock *, 32> PredCache(pred_begin(BB), pred_end(BB)); + SmallVector<BasicBlock *, 32> PredCache(predecessors(BB)); PredCache.push_back(nullptr); // null terminator. BlockToPredCountMap[BB] = PredCache.size() - 1; diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp index d89a776..dfaf36a 100644 --- a/llvm/lib/Analysis/InstructionSimplify.cpp +++ b/llvm/lib/Analysis/InstructionSimplify.cpp @@ -3599,7 +3599,7 @@ static Value *SimplifyICmpInst(unsigned Predicate, Value *LHS, Value *RHS, // expression GEP with the same indices and a null base pointer to see // what constant folding can make out of it. Constant *Null = Constant::getNullValue(GLHS->getPointerOperandType()); - SmallVector<Value *, 4> IndicesLHS(GLHS->idx_begin(), GLHS->idx_end()); + SmallVector<Value *, 4> IndicesLHS(GLHS->indices()); Constant *NewLHS = ConstantExpr::getGetElementPtr( GLHS->getSourceElementType(), Null, IndicesLHS); @@ -5814,7 +5814,7 @@ Value *llvm::SimplifyInstruction(Instruction *I, const SimplifyQuery &SQ, I->getOperand(2), Q); break; case Instruction::GetElementPtr: { - SmallVector<Value *, 8> Ops(I->op_begin(), I->op_end()); + SmallVector<Value *, 8> Ops(I->operands()); Result = SimplifyGEPInst(cast<GetElementPtrInst>(I)->getSourceElementType(), Ops, Q); break; diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index e807db0..8ec2355 100644 --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -2602,8 +2602,7 @@ const SCEV *ScalarEvolution::getAddExpr(SmallVectorImpl<const SCEV *> &Ops, // NLI + LI + {Start,+,Step} --> NLI + {LI+Start,+,Step} LIOps.push_back(AddRec->getStart()); - SmallVector<const SCEV *, 4> AddRecOps(AddRec->op_begin(), - AddRec->op_end()); + SmallVector<const SCEV *, 4> AddRecOps(AddRec->operands()); // This follows from the fact that the no-wrap flags on the outer add // expression are applicable on the 0th iteration, when the add recurrence // will be equal to its start value. @@ -2641,8 +2640,7 @@ const SCEV *ScalarEvolution::getAddExpr(SmallVectorImpl<const SCEV *> &Ops, "AddRecExprs are not sorted in reverse dominance order?"); if (AddRecLoop == cast<SCEVAddRecExpr>(Ops[OtherIdx])->getLoop()) { // Other + {A,+,B}<L> + {C,+,D}<L> --> Other + {A+C,+,B+D}<L> - SmallVector<const SCEV *, 4> AddRecOps(AddRec->op_begin(), - AddRec->op_end()); + SmallVector<const SCEV *, 4> AddRecOps(AddRec->operands()); for (; OtherIdx != Ops.size() && isa<SCEVAddRecExpr>(Ops[OtherIdx]); ++OtherIdx) { const auto *OtherAddRec = cast<SCEVAddRecExpr>(Ops[OtherIdx]); @@ -3182,8 +3180,7 @@ const SCEV *ScalarEvolution::getUDivExpr(const SCEV *LHS, const SCEV *Op = M->getOperand(i); const SCEV *Div = getUDivExpr(Op, RHSC); if (!isa<SCEVUDivExpr>(Div) && getMulExpr(Div, RHSC) == Op) { - Operands = SmallVector<const SCEV *, 4>(M->op_begin(), - M->op_end()); + Operands = SmallVector<const SCEV *, 4>(M->operands()); Operands[i] = Div; return getMulExpr(Operands); } @@ -3368,8 +3365,7 @@ ScalarEvolution::getAddRecExpr(SmallVectorImpl<const SCEV *> &Operands, ? (L->getLoopDepth() < NestedLoop->getLoopDepth()) : (!NestedLoop->contains(L) && DT.dominates(L->getHeader(), NestedLoop->getHeader()))) { - SmallVector<const SCEV *, 4> NestedOperands(NestedAR->op_begin(), - NestedAR->op_end()); + SmallVector<const SCEV *, 4> NestedOperands(NestedAR->operands()); Operands[0] = NestedAR->getStart(); // AddRecs require their operands be loop-invariant with respect to their // loops. Don't perform this transformation if it would break this @@ -11360,7 +11356,7 @@ const SCEV *SCEVAddRecExpr::getNumIterationsInRange(const ConstantRange &Range, // If the start is a non-zero constant, shift the range to simplify things. if (const SCEVConstant *SC = dyn_cast<SCEVConstant>(getStart())) if (!SC->getValue()->isZero()) { - SmallVector<const SCEV *, 4> Operands(op_begin(), op_end()); + SmallVector<const SCEV *, 4> Operands(operands()); Operands[0] = SE.getZero(SC->getType()); const SCEV *Shifted = SE.getAddRecExpr(Operands, getLoop(), getNoWrapFlags(FlagNW)); @@ -11971,7 +11967,7 @@ void ScalarEvolution::SCEVCallbackVH::allUsesReplacedWith(Value *V) { // so that future queries will recompute the expressions using the new // value. Value *Old = getValPtr(); - SmallVector<User *, 16> Worklist(Old->user_begin(), Old->user_end()); + SmallVector<User *, 16> Worklist(Old->users()); SmallPtrSet<User *, 8> Visited; while (!Worklist.empty()) { User *U = Worklist.pop_back_val(); diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp index 64b5855..82a5f9d 100644 --- a/llvm/lib/IR/Constants.cpp +++ b/llvm/lib/IR/Constants.cpp @@ -3411,7 +3411,7 @@ Value *ConstantExpr::handleOperandChangeImpl(Value *From, Value *ToV) { } Instruction *ConstantExpr::getAsInstruction() const { - SmallVector<Value *, 4> ValueOperands(op_begin(), op_end()); + SmallVector<Value *, 4> ValueOperands(operands()); ArrayRef<Value*> Ops(ValueOperands); switch (getOpcode()) { diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index 1100d8d..5692493 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -2566,7 +2566,7 @@ void Verifier::visitBasicBlock(BasicBlock &BB) { // Check constraints that this basic block imposes on all of the PHI nodes in // it. if (isa<PHINode>(BB.front())) { - SmallVector<BasicBlock*, 8> Preds(pred_begin(&BB), pred_end(&BB)); + SmallVector<BasicBlock *, 8> Preds(predecessors(&BB)); SmallVector<std::pair<BasicBlock*, Value*>, 8> Values; llvm::sort(Preds); for (const PHINode &PN : BB.phis()) { @@ -3495,7 +3495,7 @@ void Verifier::visitGetElementPtrInst(GetElementPtrInst &GEP) { "GEP base pointer is not a vector or a vector of pointers", &GEP); Assert(GEP.getSourceElementType()->isSized(), "GEP into unsized type!", &GEP); - SmallVector<Value*, 16> Idxs(GEP.idx_begin(), GEP.idx_end()); + SmallVector<Value *, 16> Idxs(GEP.indices()); Assert(all_of( Idxs, [](Value* V) { return V->getType()->isIntOrIntVectorTy(); }), "GEP indexes must be integers", &GEP); diff --git a/llvm/lib/TableGen/Record.cpp b/llvm/lib/TableGen/Record.cpp index 3e6daeb4..afd7254 100644 --- a/llvm/lib/TableGen/Record.cpp +++ b/llvm/lib/TableGen/Record.cpp @@ -232,9 +232,7 @@ bool RecordRecTy::typeIsA(const RecTy *RHS) const { static RecordRecTy *resolveRecordTypes(RecordRecTy *T1, RecordRecTy *T2) { SmallVector<Record *, 4> CommonSuperClasses; - SmallVector<Record *, 4> Stack; - - Stack.insert(Stack.end(), T1->classes_begin(), T1->classes_end()); + SmallVector<Record *, 4> Stack(T1->classes_begin(), T1->classes_end()); while (!Stack.empty()) { Record *R = Stack.back(); |