[PATCH] D130778: [NFC] Simplify some conversions from ArrayRef to SmallVector by using to_vector and to_vector_of utilities
Dawid Jurczak via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 29 07:33:01 PDT 2022
yurai007 created this revision.
yurai007 added reviewers: nikic, dblaikie, wolfgangp, dexonsmith, jhenderson.
Herald added subscribers: jeroen.dobbelaere, rupprecht, hiraditya.
Herald added a project: All.
yurai007 requested review of this revision.
Herald added subscribers: llvm-commits, MaskRay.
Herald added a project: LLVM.
Extracted from/depends on: https://reviews.llvm.org/D129781
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D130778
Files:
llvm/include/llvm/IR/Metadata.h
llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp
llvm/lib/Linker/IRMover.cpp
llvm/tools/llvm-rc/ResourceScriptStmt.h
llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp
llvm/unittests/Analysis/VectorUtilsTest.cpp
Index: llvm/unittests/Analysis/VectorUtilsTest.cpp
===================================================================
--- llvm/unittests/Analysis/VectorUtilsTest.cpp
+++ llvm/unittests/Analysis/VectorUtilsTest.cpp
@@ -507,8 +507,7 @@
}
bool validParams(ArrayRef<VFParameter> Parameters) {
- Shape.Parameters =
- SmallVector<VFParameter, 8>(Parameters.begin(), Parameters.end());
+ Shape.Parameters = llvm::to_vector<8>(Parameters);
return Shape.hasValidParameterList();
}
};
Index: llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp
===================================================================
--- llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp
+++ llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp
@@ -125,7 +125,7 @@
return {};
ArrayRef<uint8_t> BuildID(reinterpret_cast<const uint8_t *>(Bytes.data()),
Bytes.size());
- return SmallVector<uint8_t>(BuildID.begin(), BuildID.end());
+ return llvm::to_vector(BuildID);
}
static bool parseCommand(StringRef BinaryName, bool IsAddr2Line,
Index: llvm/tools/llvm-rc/ResourceScriptStmt.h
===================================================================
--- llvm/tools/llvm-rc/ResourceScriptStmt.h
+++ llvm/tools/llvm-rc/ResourceScriptStmt.h
@@ -817,7 +817,7 @@
VersionInfoFixed() : IsTypePresent(FtNumTypes, false) {}
void setValue(VersionInfoFixedType Type, ArrayRef<uint32_t> Value) {
- FixedInfo[Type] = SmallVector<uint32_t, 4>(Value.begin(), Value.end());
+ FixedInfo[Type] = llvm::to_vector<4>(Value);
IsTypePresent[Type] = true;
}
Index: llvm/lib/Linker/IRMover.cpp
===================================================================
--- llvm/lib/Linker/IRMover.cpp
+++ llvm/lib/Linker/IRMover.cpp
@@ -1372,10 +1372,9 @@
"Expected MDTuple when appending module flags");
if (DstValue->isDistinct())
return dyn_cast<MDTuple>(DstValue);
- ArrayRef<MDOperand> DstOperands = DstValue->operands();
MDTuple *New = MDTuple::getDistinct(
DstM.getContext(),
- SmallVector<Metadata *, 4>(DstOperands.begin(), DstOperands.end()));
+ llvm::to_vector_of<Metadata *, 4>(DstValue->operands()));
Metadata *FlagOps[] = {DstOp->getOperand(0), ID, New};
MDNode *Flag = MDTuple::getDistinct(DstM.getContext(), FlagOps);
DstModFlags->setOperand(DstIndex, Flag);
Index: llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp
===================================================================
--- llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp
+++ llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp
@@ -811,8 +811,7 @@
return nullptr;
// Otherwise, create TBAA with the new Len
- ArrayRef<MDOperand> MDOperands = MD->operands();
- SmallVector<Metadata *, 4> NextNodes(MDOperands.begin(), MDOperands.end());
+ auto NextNodes = to_vector_of<Metadata *, 4>(MD->operands());
ConstantInt *PreviousSize = mdconst::extract<ConstantInt>(NextNodes[3]);
// Don't create a new MDNode if it is the same length.
Index: llvm/include/llvm/IR/Metadata.h
===================================================================
--- llvm/include/llvm/IR/Metadata.h
+++ llvm/include/llvm/IR/Metadata.h
@@ -1345,9 +1345,8 @@
StorageType Storage, bool ShouldCreate = true);
TempMDTuple cloneImpl() const {
- ArrayRef<MDOperand> Operands = operands();
- return getTemporary(getContext(), SmallVector<Metadata *, 4>(
- Operands.begin(), Operands.end()));
+ return getTemporary(getContext(),
+ llvm::to_vector_of<Metadata *, 4>(operands()));
}
public:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D130778.448627.patch
Type: text/x-patch
Size: 3670 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220729/4f4720ec/attachment.bin>
More information about the llvm-commits
mailing list