Skip to content

Commit 7df9da7

Browse files
[llvm] Construct SmallVector with ArrayRef (NFC) (#101872)
1 parent 2e9d2f1 commit 7df9da7

26 files changed

+31
-38
lines changed

llvm/include/llvm/Analysis/TargetTransformInfoImpl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1389,7 +1389,7 @@ class TargetTransformInfoImplCRTPBase : public TargetTransformInfoImplBase {
13891389

13901390
bool IsUnary = isa<UndefValue>(Operands[1]);
13911391
NumSubElts = VecSrcTy->getElementCount().getKnownMinValue();
1392-
SmallVector<int, 16> AdjustMask(Mask.begin(), Mask.end());
1392+
SmallVector<int, 16> AdjustMask(Mask);
13931393

13941394
// Widening shuffle - widening the source(s) to the new length
13951395
// (treated as free - see above), and then perform the adjusted

llvm/include/llvm/DebugInfo/CodeView/TypeRecord.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -669,8 +669,7 @@ class BuildInfoRecord : public TypeRecord {
669669
BuildInfoRecord() = default;
670670
explicit BuildInfoRecord(TypeRecordKind Kind) : TypeRecord(Kind) {}
671671
BuildInfoRecord(ArrayRef<TypeIndex> ArgIndices)
672-
: TypeRecord(TypeRecordKind::BuildInfo),
673-
ArgIndices(ArgIndices.begin(), ArgIndices.end()) {}
672+
: TypeRecord(TypeRecordKind::BuildInfo), ArgIndices(ArgIndices) {}
674673

675674
ArrayRef<TypeIndex> getArgs() const { return ArgIndices; }
676675

llvm/include/llvm/FuzzMutate/RandomIRBuilder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ struct RandomIRBuilder {
4343
uint64_t MinFunctionNum = 1;
4444

4545
RandomIRBuilder(int Seed, ArrayRef<Type *> AllowedTypes)
46-
: Rand(Seed), KnownTypes(AllowedTypes.begin(), AllowedTypes.end()) {}
46+
: Rand(Seed), KnownTypes(AllowedTypes) {}
4747

4848
// TODO: Try to make this a bit less of a random mishmash of functions.
4949

llvm/include/llvm/IR/DebugInfoMetadata.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3946,7 +3946,7 @@ class DIArgList : public Metadata, ReplaceableMetadataImpl {
39463946

39473947
DIArgList(LLVMContext &Context, ArrayRef<ValueAsMetadata *> Args)
39483948
: Metadata(DIArgListKind, Uniqued), ReplaceableMetadataImpl(Context),
3949-
Args(Args.begin(), Args.end()) {
3949+
Args(Args) {
39503950
track();
39513951
}
39523952
~DIArgList() { untrack(); }

llvm/include/llvm/IR/Metadata.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1489,8 +1489,7 @@ class MDTuple : public MDNode {
14891489

14901490
TempMDTuple cloneImpl() const {
14911491
ArrayRef<MDOperand> Operands = operands();
1492-
return getTemporary(getContext(), SmallVector<Metadata *, 4>(
1493-
Operands.begin(), Operands.end()));
1492+
return getTemporary(getContext(), SmallVector<Metadata *, 4>(Operands));
14941493
}
14951494

14961495
public:

llvm/include/llvm/MC/MCFragment.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -513,8 +513,7 @@ class MCCVDefRangeFragment : public MCEncodedFragmentWithFixups<32, 4> {
513513
ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
514514
StringRef FixedSizePortion)
515515
: MCEncodedFragmentWithFixups<32, 4>(FT_CVDefRange, false),
516-
Ranges(Ranges.begin(), Ranges.end()),
517-
FixedSizePortion(FixedSizePortion) {}
516+
Ranges(Ranges), FixedSizePortion(FixedSizePortion) {}
518517

519518
ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> getRanges() const {
520519
return Ranges;

llvm/include/llvm/ProfileData/MemProf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ struct IndexedAllocationInfo {
352352
IndexedAllocationInfo(ArrayRef<FrameId> CS, CallStackId CSId,
353353
const MemInfoBlock &MB,
354354
const MemProfSchema &Schema = getFullSchema())
355-
: CallStack(CS.begin(), CS.end()), CSId(CSId), Info(MB, Schema) {}
355+
: CallStack(CS), CSId(CSId), Info(MB, Schema) {}
356356

357357
// Returns the size in bytes when this allocation info struct is serialized.
358358
size_t serializedSize(const MemProfSchema &Schema,

llvm/include/llvm/Support/GenericDomTree.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ class DominatorTreeBase {
574574
// The PostViewCFG is created with updates reversed (equivalent to changes
575575
// made to the CFG), so the PreViewCFG needs all the updates reverse
576576
// applied.
577-
SmallVector<UpdateType> AllUpdates(Updates.begin(), Updates.end());
577+
SmallVector<UpdateType> AllUpdates(Updates);
578578
append_range(AllUpdates, PostViewUpdates);
579579
GraphDiff<NodePtr, IsPostDom> PreViewCFG(AllUpdates,
580580
/*ReverseApplyUpdates=*/true);

llvm/include/llvm/Support/ScopedPrinter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ class ScopedPrinter {
161161
void printFlags(StringRef Label, T Value, ArrayRef<EnumEntry<TFlag>> Flags,
162162
TFlag EnumMask1 = {}, TFlag EnumMask2 = {},
163163
TFlag EnumMask3 = {}, ArrayRef<FlagEntry> ExtraFlags = {}) {
164-
SmallVector<FlagEntry, 10> SetFlags(ExtraFlags.begin(), ExtraFlags.end());
164+
SmallVector<FlagEntry, 10> SetFlags(ExtraFlags);
165165

166166
for (const auto &Flag : Flags) {
167167
if (Flag.Value == 0)

llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,7 @@ MDNode *AAMDNodes::extendToTBAA(MDNode *MD, ssize_t Len) {
807807

808808
// Otherwise, create TBAA with the new Len
809809
ArrayRef<MDOperand> MDOperands = MD->operands();
810-
SmallVector<Metadata *, 4> NextNodes(MDOperands.begin(), MDOperands.end());
810+
SmallVector<Metadata *, 4> NextNodes(MDOperands);
811811
ConstantInt *PreviousSize = mdconst::extract<ConstantInt>(NextNodes[3]);
812812

813813
// Don't create a new MDNode if it is the same length.

llvm/lib/Analysis/ValueTracking.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6122,7 +6122,7 @@ static Value *BuildSubAggregate(Value *From, ArrayRef<unsigned> idx_range,
61226122
Type *IndexedType = ExtractValueInst::getIndexedType(From->getType(),
61236123
idx_range);
61246124
Value *To = PoisonValue::get(IndexedType);
6125-
SmallVector<unsigned, 10> Idxs(idx_range.begin(), idx_range.end());
6125+
SmallVector<unsigned, 10> Idxs(idx_range);
61266126
unsigned IdxSkip = Idxs.size();
61276127

61286128
return BuildSubAggregate(From, To, IndexedType, Idxs, IdxSkip, InsertBefore);

llvm/lib/IR/Attributes.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1040,7 +1040,7 @@ AttributeSetNode::AttributeSetNode(ArrayRef<Attribute> Attrs)
10401040

10411041
AttributeSetNode *AttributeSetNode::get(LLVMContext &C,
10421042
ArrayRef<Attribute> Attrs) {
1043-
SmallVector<Attribute, 8> SortedAttrs(Attrs.begin(), Attrs.end());
1043+
SmallVector<Attribute, 8> SortedAttrs(Attrs);
10441044
llvm::sort(SortedAttrs);
10451045
return getSorted(C, SortedAttrs);
10461046
}

llvm/lib/IR/DebugInfoMetadata.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1861,7 +1861,7 @@ DIExpression *DIExpression::appendOpsToArg(const DIExpression *Expr,
18611861
[](auto Op) { return Op.getOp() == dwarf::DW_OP_LLVM_arg; })) {
18621862
assert(ArgNo == 0 &&
18631863
"Location Index must be 0 for a non-variadic expression.");
1864-
SmallVector<uint64_t, 8> NewOps(Ops.begin(), Ops.end());
1864+
SmallVector<uint64_t, 8> NewOps(Ops);
18651865
return DIExpression::prependOpcodes(Expr, NewOps, StackValue);
18661866
}
18671867

llvm/lib/Linker/IRMover.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1371,8 +1371,7 @@ Error IRLinker::linkModuleFlagsMetadata() {
13711371
return dyn_cast<MDTuple>(DstValue);
13721372
ArrayRef<MDOperand> DstOperands = DstValue->operands();
13731373
MDTuple *New = MDTuple::getDistinct(
1374-
DstM.getContext(),
1375-
SmallVector<Metadata *, 4>(DstOperands.begin(), DstOperands.end()));
1374+
DstM.getContext(), SmallVector<Metadata *, 4>(DstOperands));
13761375
Metadata *FlagOps[] = {DstOp->getOperand(0), ID, New};
13771376
MDNode *Flag = MDTuple::getDistinct(DstM.getContext(), FlagOps);
13781377
DstModFlags->setOperand(DstIndex, Flag);

llvm/lib/Object/BuildID.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ BuildID llvm::object::parseBuildID(StringRef Str) {
5050
return {};
5151
ArrayRef<uint8_t> BuildID(reinterpret_cast<const uint8_t *>(Bytes.data()),
5252
Bytes.size());
53-
return SmallVector<uint8_t>(BuildID.begin(), BuildID.end());
53+
return SmallVector<uint8_t>(BuildID);
5454
}
5555

5656
BuildIDRef llvm::object::getBuildID(const ObjectFile *Obj) {

llvm/lib/Support/SourceMgr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ SMDiagnostic::SMDiagnostic(const SourceMgr &sm, SMLoc L, StringRef FN, int Line,
382382
ArrayRef<SMFixIt> Hints)
383383
: SM(&sm), Loc(L), Filename(std::string(FN)), LineNo(Line), ColumnNo(Col),
384384
Kind(Kind), Message(Msg), LineContents(LineStr), Ranges(Ranges.vec()),
385-
FixIts(Hints.begin(), Hints.end()) {
385+
FixIts(Hints) {
386386
llvm::sort(FixIts);
387387
}
388388

llvm/lib/Support/VirtualFileSystem.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ class CombiningDirIterImpl : public llvm::vfs::detail::DirIterImpl {
591591

592592
CombiningDirIterImpl(ArrayRef<directory_iterator> DirIters,
593593
std::error_code &EC)
594-
: IterList(DirIters.begin(), DirIters.end()) {
594+
: IterList(DirIters) {
595595
EC = incrementImpl(true);
596596
}
597597

llvm/lib/Target/Hexagon/HexagonISelLowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2274,7 +2274,7 @@ HexagonTargetLowering::LowerVECTOR_SHUFFLE(SDValue Op, SelectionDAG &DAG)
22742274

22752275
// Normalize the mask so that the first non-negative index comes from
22762276
// the first operand.
2277-
SmallVector<int,8> Mask(AM.begin(), AM.end());
2277+
SmallVector<int, 8> Mask(AM);
22782278
unsigned F = llvm::find_if(AM, [](int M) { return M >= 0; }) - AM.data();
22792279
if (F == AM.size())
22802280
return DAG.getUNDEF(VecTy);

llvm/lib/Target/Hexagon/HexagonISelLoweringHVX.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1725,7 +1725,7 @@ HexagonTargetLowering::LowerHvxConcatVectors(SDValue Op, SelectionDAG &DAG)
17251725
return DAG.getNode(HexagonISD::QCAT, dl, VecTy, Op0, Op.getOperand(1));
17261726

17271727
ArrayRef<SDUse> U(Op.getNode()->ops());
1728-
SmallVector<SDValue,4> SV(U.begin(), U.end());
1728+
SmallVector<SDValue, 4> SV(U);
17291729
ArrayRef<SDValue> Ops(SV);
17301730

17311731
MVT HalfTy = typeSplit(VecTy).first;
@@ -2128,7 +2128,7 @@ SDValue
21282128
HexagonTargetLowering::LowerHvxIntrinsic(SDValue Op, SelectionDAG &DAG) const {
21292129
const SDLoc &dl(Op);
21302130
unsigned IntNo = Op.getConstantOperandVal(0);
2131-
SmallVector<SDValue> Ops(Op->ops().begin(), Op->ops().end());
2131+
SmallVector<SDValue> Ops(Op->ops());
21322132

21332133
auto Swap = [&](SDValue P) {
21342134
return DAG.getMergeValues({P.getValue(1), P.getValue(0)}, dl);
@@ -3589,7 +3589,7 @@ HexagonTargetLowering::PerformHvxDAGCombine(SDNode *N, DAGCombinerInfo &DCI)
35893589
SDValue Op(N, 0);
35903590
unsigned Opc = Op.getOpcode();
35913591

3592-
SmallVector<SDValue, 4> Ops(N->ops().begin(), N->ops().end());
3592+
SmallVector<SDValue, 4> Ops(N->ops());
35933593

35943594
if (Opc == ISD::TRUNCATE)
35953595
return combineTruncateBeforeLegal(Op, DCI);

llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2691,7 +2691,7 @@ auto HexagonVectorCombine::joinVectorElements(IRBuilderBase &Builder,
26912691
// joins, the shuffles will hopefully be folded into a perfect shuffle.
26922692
// The output will need to be sign-extended to a type with element width
26932693
// being a power-of-2 anyways.
2694-
SmallVector<Value *> Inputs(Values.begin(), Values.end());
2694+
SmallVector<Value *> Inputs(Values);
26952695

26962696
unsigned ToWidth = ToType->getScalarSizeInBits();
26972697
unsigned Width = Inputs.front()->getType()->getScalarSizeInBits();

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4295,7 +4295,7 @@ static SDValue getAVX512Node(unsigned Opcode, const SDLoc &DL, MVT VT,
42954295
DstVT = MVT::getVectorVT(SVT, 512 / SVT.getSizeInBits());
42964296

42974297
// Canonicalize src operands.
4298-
SmallVector<SDValue> SrcOps(Ops.begin(), Ops.end());
4298+
SmallVector<SDValue> SrcOps(Ops);
42994299
for (SDValue &Op : SrcOps) {
43004300
MVT OpVT = Op.getSimpleValueType();
43014301
// Just pass through scalar operands.
@@ -39298,7 +39298,7 @@ static SDValue combineX86ShuffleChainWithExtract(
3929839298
// Attempt to peek through inputs and adjust mask when we extract from an
3929939299
// upper subvector.
3930039300
int AdjustedMasks = 0;
39301-
SmallVector<SDValue, 4> WideInputs(Inputs.begin(), Inputs.end());
39301+
SmallVector<SDValue, 4> WideInputs(Inputs);
3930239302
for (unsigned I = 0; I != NumInputs; ++I) {
3930339303
SDValue &Input = WideInputs[I];
3930439304
Input = peekThroughBitcasts(Input);
@@ -39983,8 +39983,7 @@ static SDValue combineX86ShufflesRecursively(
3998339983
HasVariableMask |= IsOpVariableMask;
3998439984

3998539985
// Update the list of shuffle nodes that have been combined so far.
39986-
SmallVector<const SDNode *, 16> CombinedNodes(SrcNodes.begin(),
39987-
SrcNodes.end());
39986+
SmallVector<const SDNode *, 16> CombinedNodes(SrcNodes);
3998839987
CombinedNodes.push_back(Op.getNode());
3998939988

3999039989
// See if we can recurse into each shuffle source op (if it's a target

llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ int llvm::libDriverMain(ArrayRef<const char *> ArgsArr) {
312312
StringSaver Saver(Alloc);
313313

314314
// Parse command line arguments.
315-
SmallVector<const char *, 20> NewArgs(ArgsArr.begin(), ArgsArr.end());
315+
SmallVector<const char *, 20> NewArgs(ArgsArr);
316316
cl::ExpandResponseFiles(Saver, cl::TokenizeWindowsCommandLine, NewArgs);
317317
ArgsArr = NewArgs;
318318

llvm/tools/dsymutil/MachODebugMapParser.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,8 @@ class MachODebugMapParser {
3232
ArrayRef<std::string> DSYMSearchPaths,
3333
StringRef PathPrefix = "", StringRef VariantSuffix = "",
3434
bool Verbose = false)
35-
: BinaryPath(std::string(BinaryPath)), Archs(Archs.begin(), Archs.end()),
36-
DSYMSearchPaths(DSYMSearchPaths.begin(), DSYMSearchPaths.end()),
37-
PathPrefix(std::string(PathPrefix)),
35+
: BinaryPath(std::string(BinaryPath)), Archs(Archs),
36+
DSYMSearchPaths(DSYMSearchPaths), PathPrefix(std::string(PathPrefix)),
3837
VariantSuffix(std::string(VariantSuffix)), BinHolder(VFS, Verbose),
3938
CurrentDebugMapObject(nullptr), SkipDebugMapObject(false) {}
4039

llvm/tools/llvm-rc/ResourceScriptStmt.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,7 @@ class VersionInfoResource : public RCResource {
875875
VersionInfoFixed() : IsTypePresent(FtNumTypes, false) {}
876876

877877
void setValue(VersionInfoFixedType Type, ArrayRef<uint32_t> Value) {
878-
FixedInfo[Type] = SmallVector<uint32_t, 4>(Value.begin(), Value.end());
878+
FixedInfo[Type] = SmallVector<uint32_t, 4>(Value);
879879
IsTypePresent[Type] = true;
880880
}
881881

llvm/unittests/Analysis/VectorUtilsTest.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -607,8 +607,7 @@ class VFShapeAPITest : public testing::Test {
607607
}
608608

609609
bool validParams(ArrayRef<VFParameter> Parameters) {
610-
Shape.Parameters =
611-
SmallVector<VFParameter, 8>(Parameters.begin(), Parameters.end());
610+
Shape.Parameters = SmallVector<VFParameter, 8>(Parameters);
612611
return Shape.hasValidParameterList();
613612
}
614613
};

llvm/unittests/Support/VirtualFileSystemTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,7 @@ TEST(VirtualFileSystemTest, BrokenSymlinkRealFSRecursiveIteration) {
766766
template <typename DirIter>
767767
static void checkContents(DirIter I, ArrayRef<StringRef> ExpectedOut) {
768768
std::error_code EC;
769-
SmallVector<StringRef, 4> Expected(ExpectedOut.begin(), ExpectedOut.end());
769+
SmallVector<StringRef, 4> Expected(ExpectedOut);
770770
SmallVector<std::string, 4> InputToCheck;
771771

772772
// Do not rely on iteration order to check for contents, sort both

0 commit comments

Comments
 (0)