[llvm] Construct SmallVector with iterator ranges (NFC) (#136064)
diff --git a/llvm/lib/Analysis/VectorUtils.cpp b/llvm/lib/Analysis/VectorUtils.cpp
index 62f1555..6448c37 100644
--- a/llvm/lib/Analysis/VectorUtils.cpp
+++ b/llvm/lib/Analysis/VectorUtils.cpp
@@ -1703,9 +1703,7 @@
namespace llvm {
template <>
void InterleaveGroup<Instruction>::addMetadata(Instruction *NewInst) const {
- SmallVector<Value *, 4> VL;
- std::transform(Members.begin(), Members.end(), std::back_inserter(VL),
- [](std::pair<int, Instruction *> p) { return p.second; });
+ SmallVector<Value *, 4> VL(make_second_range(Members));
propagateMetadata(NewInst, VL);
}
} // namespace llvm
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index e3f6c1a..765befc 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/lib/IR/Verifier.cpp
@@ -720,8 +720,7 @@
if (!Visited.insert(User).second)
return;
- SmallVector<const Value *> WorkList;
- append_range(WorkList, User->materialized_users());
+ SmallVector<const Value *> WorkList(User->materialized_users());
while (!WorkList.empty()) {
const Value *Cur = WorkList.pop_back_val();
if (!Visited.insert(Cur).second)
diff --git a/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp b/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
index 80a0df7..0ec5202 100644
--- a/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
+++ b/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
@@ -382,9 +382,8 @@
// Cleanup the code from the dead instructions: GEPs and BitCasts in between
// the original argument and its users: loads and stores. Retarget every
// user to the new created alloca.
- SmallVector<Value *, 16> Worklist;
+ SmallVector<Value *, 16> Worklist(Arg.users());
SmallVector<Instruction *, 16> DeadInsts;
- append_range(Worklist, Arg.users());
while (!Worklist.empty()) {
Value *V = Worklist.pop_back_val();
if (isa<GetElementPtrInst>(V)) {
diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
index cc9e524..f807f5f 100644
--- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -2500,9 +2500,8 @@
return nullptr;
GEPNoWrapFlags NW = getMergedGEPNoWrapFlags(*Src, *cast<GEPOperator>(&GEP));
- SmallVector<Value *> Indices;
- append_range(Indices, drop_end(Src->indices(),
- Src->getNumIndices() - NumVarIndices));
+ SmallVector<Value *> Indices(
+ drop_end(Src->indices(), Src->getNumIndices() - NumVarIndices));
for (const APInt &Idx : drop_begin(ConstIndices, !IsFirstType)) {
Indices.push_back(ConstantInt::get(GEP.getContext(), Idx));
// Even if the total offset is inbounds, we may end up representing it