Skip to content

[CodeGen] Construct SmallVector with ArrayRef (NFC) #101841

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions llvm/include/llvm/CodeGen/GlobalISel/CallLowering.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class CallLowering {
BaseArgInfo(Type *Ty,
ArrayRef<ISD::ArgFlagsTy> Flags = ArrayRef<ISD::ArgFlagsTy>(),
bool IsFixed = true)
: Ty(Ty), Flags(Flags.begin(), Flags.end()), IsFixed(IsFixed) {}
: Ty(Ty), Flags(Flags), IsFixed(IsFixed) {}

BaseArgInfo() : Ty(nullptr), IsFixed(false) {}
};
Expand All @@ -81,8 +81,8 @@ class CallLowering {
ArgInfo(ArrayRef<Register> Regs, Type *Ty, unsigned OrigIndex,
ArrayRef<ISD::ArgFlagsTy> Flags = ArrayRef<ISD::ArgFlagsTy>(),
bool IsFixed = true, const Value *OrigValue = nullptr)
: BaseArgInfo(Ty, Flags, IsFixed), Regs(Regs.begin(), Regs.end()),
OrigValue(OrigValue), OrigArgIndex(OrigIndex) {
: BaseArgInfo(Ty, Flags, IsFixed), Regs(Regs), OrigValue(OrigValue),
OrigArgIndex(OrigIndex) {
if (!Regs.empty() && Flags.empty())
this->Flags.push_back(ISD::ArgFlagsTy());
// FIXME: We should have just one way of saying "no register".
Expand Down
3 changes: 1 addition & 2 deletions llvm/include/llvm/CodeGen/GlobalISel/GISelChangeObserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ class GISelObserverWrapper : public MachineFunction::Delegate,

public:
GISelObserverWrapper() = default;
GISelObserverWrapper(ArrayRef<GISelChangeObserver *> Obs)
: Observers(Obs.begin(), Obs.end()) {}
GISelObserverWrapper(ArrayRef<GISelChangeObserver *> Obs) : Observers(Obs) {}
// Adds an observer.
void addObserver(GISelChangeObserver *O) { Observers.push_back(O); }
// Removes an observer from the list and does nothing if observer is not
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class AppleAccelTableWriter : public AccelTableWriter {
const SmallVector<Atom, 4> Atoms;

HeaderData(ArrayRef<Atom> AtomList, uint32_t Offset = 0)
: DieOffsetBase(Offset), Atoms(AtomList.begin(), AtomList.end()) {}
: DieOffsetBase(Offset), Atoms(AtomList) {}

void emit(AsmPrinter *Asm) const;
#ifndef NDEBUG
Expand Down
6 changes: 2 additions & 4 deletions llvm/lib/CodeGen/AsmPrinter/DebugLocEntry.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,11 @@ class DbgValueLoc {

public:
DbgValueLoc(const DIExpression *Expr, ArrayRef<DbgValueLocEntry> Locs)
: Expression(Expr), ValueLocEntries(Locs.begin(), Locs.end()),
IsVariadic(true) {}
: Expression(Expr), ValueLocEntries(Locs), IsVariadic(true) {}

DbgValueLoc(const DIExpression *Expr, ArrayRef<DbgValueLocEntry> Locs,
bool IsVariadic)
: Expression(Expr), ValueLocEntries(Locs.begin(), Locs.end()),
IsVariadic(IsVariadic) {
: Expression(Expr), ValueLocEntries(Locs), IsVariadic(IsVariadic) {
#ifndef NDEBUG
assert(Expr->isValid() ||
!any_of(Locs, [](auto LE) { return LE.isLocation(); }));
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/CodeGen/GlobalISel/CallLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ static void buildCopyFromRegs(MachineIRBuilder &B, ArrayRef<Register> OrigRegs,

if (PartLLT.isVector()) {
assert(OrigRegs.size() == 1);
SmallVector<Register> CastRegs(Regs.begin(), Regs.end());
SmallVector<Register> CastRegs(Regs);

// If PartLLT is a mismatched vector in both number of elements and element
// size, e.g. PartLLT == v2s64 and LLTy is v3s32, then first coerce it to
Expand Down
14 changes: 7 additions & 7 deletions llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ MachineInstrBuilder MachineIRBuilder::buildMergeValues(const DstOp &Res,
// Unfortunately to convert from ArrayRef<LLT> to ArrayRef<SrcOp>,
// we need some temporary storage for the DstOp objects. Here we use a
// sufficiently large SmallVector to not go through the heap.
SmallVector<SrcOp, 8> TmpVec(Ops.begin(), Ops.end());
SmallVector<SrcOp, 8> TmpVec(Ops);
assert(TmpVec.size() > 1);
return buildInstr(TargetOpcode::G_MERGE_VALUES, Res, TmpVec);
}
Expand All @@ -657,7 +657,7 @@ MachineIRBuilder::buildMergeLikeInstr(const DstOp &Res,
// Unfortunately to convert from ArrayRef<LLT> to ArrayRef<SrcOp>,
// we need some temporary storage for the DstOp objects. Here we use a
// sufficiently large SmallVector to not go through the heap.
SmallVector<SrcOp, 8> TmpVec(Ops.begin(), Ops.end());
SmallVector<SrcOp, 8> TmpVec(Ops);
assert(TmpVec.size() > 1);
return buildInstr(getOpcodeForMerge(Res, TmpVec), Res, TmpVec);
}
Expand Down Expand Up @@ -685,7 +685,7 @@ MachineInstrBuilder MachineIRBuilder::buildUnmerge(ArrayRef<LLT> Res,
// Unfortunately to convert from ArrayRef<LLT> to ArrayRef<DstOp>,
// we need some temporary storage for the DstOp objects. Here we use a
// sufficiently large SmallVector to not go through the heap.
SmallVector<DstOp, 8> TmpVec(Res.begin(), Res.end());
SmallVector<DstOp, 8> TmpVec(Res);
assert(TmpVec.size() > 1);
return buildInstr(TargetOpcode::G_UNMERGE_VALUES, TmpVec, Op);
}
Expand All @@ -702,7 +702,7 @@ MachineInstrBuilder MachineIRBuilder::buildUnmerge(ArrayRef<Register> Res,
// Unfortunately to convert from ArrayRef<Register> to ArrayRef<DstOp>,
// we need some temporary storage for the DstOp objects. Here we use a
// sufficiently large SmallVector to not go through the heap.
SmallVector<DstOp, 8> TmpVec(Res.begin(), Res.end());
SmallVector<DstOp, 8> TmpVec(Res);
assert(TmpVec.size() > 1);
return buildInstr(TargetOpcode::G_UNMERGE_VALUES, TmpVec, Op);
}
Expand All @@ -712,7 +712,7 @@ MachineInstrBuilder MachineIRBuilder::buildBuildVector(const DstOp &Res,
// Unfortunately to convert from ArrayRef<Register> to ArrayRef<SrcOp>,
// we need some temporary storage for the DstOp objects. Here we use a
// sufficiently large SmallVector to not go through the heap.
SmallVector<SrcOp, 8> TmpVec(Ops.begin(), Ops.end());
SmallVector<SrcOp, 8> TmpVec(Ops);
return buildInstr(TargetOpcode::G_BUILD_VECTOR, Res, TmpVec);
}

Expand All @@ -739,7 +739,7 @@ MachineIRBuilder::buildBuildVectorTrunc(const DstOp &Res,
// Unfortunately to convert from ArrayRef<Register> to ArrayRef<SrcOp>,
// we need some temporary storage for the DstOp objects. Here we use a
// sufficiently large SmallVector to not go through the heap.
SmallVector<SrcOp, 8> TmpVec(Ops.begin(), Ops.end());
SmallVector<SrcOp, 8> TmpVec(Ops);
if (TmpVec[0].getLLTTy(*getMRI()).getSizeInBits() ==
Res.getLLTTy(*getMRI()).getElementType().getSizeInBits())
return buildInstr(TargetOpcode::G_BUILD_VECTOR, Res, TmpVec);
Expand Down Expand Up @@ -789,7 +789,7 @@ MachineIRBuilder::buildConcatVectors(const DstOp &Res, ArrayRef<Register> Ops) {
// Unfortunately to convert from ArrayRef<Register> to ArrayRef<SrcOp>,
// we need some temporary storage for the DstOp objects. Here we use a
// sufficiently large SmallVector to not go through the heap.
SmallVector<SrcOp, 8> TmpVec(Ops.begin(), Ops.end());
SmallVector<SrcOp, 8> TmpVec(Ops);
return buildInstr(TargetOpcode::G_CONCAT_VECTORS, Res, TmpVec);
}

Expand Down
3 changes: 1 addition & 2 deletions llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,7 @@ class TransferTracker {
DbgValueProperties Properties;
UseBeforeDef(ArrayRef<DbgOp> Values, DebugVariableID VarID,
const DbgValueProperties &Properties)
: Values(Values.begin(), Values.end()), VarID(VarID),
Properties(Properties) {}
: Values(Values), VarID(VarID), Properties(Properties) {}
};

/// Map from instruction index (within the block) to the set of UseBeforeDefs
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/CodeGen/LiveIntervals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1681,7 +1681,7 @@ LiveIntervals::repairIntervalsInRange(MachineBasicBlock *MBB,
Indexes->repairIndexesInRange(MBB, Begin, End);

// Make sure a live interval exists for all register operands in the range.
SmallVector<Register> RegsToRepair(OrigRegs.begin(), OrigRegs.end());
SmallVector<Register> RegsToRepair(OrigRegs);
for (MachineBasicBlock::iterator I = End; I != Begin;) {
--I;
MachineInstr &MI = *I;
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/CodeGen/MachineScheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1742,8 +1742,8 @@ class BaseMemOpClusterMutation : public ScheduleDAGMutation {

MemOpInfo(SUnit *SU, ArrayRef<const MachineOperand *> BaseOps,
int64_t Offset, bool OffsetIsScalable, LocationSize Width)
: SU(SU), BaseOps(BaseOps.begin(), BaseOps.end()), Offset(Offset),
Width(Width), OffsetIsScalable(OffsetIsScalable) {}
: SU(SU), BaseOps(BaseOps), Offset(Offset), Width(Width),
OffsetIsScalable(OffsetIsScalable) {}

static bool Compare(const MachineOperand *const &A,
const MachineOperand *const &B) {
Expand Down
5 changes: 2 additions & 3 deletions llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25241,7 +25241,7 @@ static SDValue combineShuffleToZeroExtendVectorInReg(ShuffleVectorSDNode *SVN,
if (!VT.isInteger() || IsBigEndian)
return SDValue();

SmallVector<int, 16> Mask(SVN->getMask().begin(), SVN->getMask().end());
SmallVector<int, 16> Mask(SVN->getMask());
auto ForEachDecomposedIndice = [NumElts, &Mask](auto Fn) {
for (int &Indice : Mask) {
if (Indice < 0)
Expand Down Expand Up @@ -25444,8 +25444,7 @@ static SDValue combineShuffleOfSplatVal(ShuffleVectorSDNode *Shuf,
if (!MinNonUndefIdx)
return DAG.getUNDEF(VT); // All undef - result is undef.
assert(*MinNonUndefIdx < NumElts && "Expected valid element index.");
SmallVector<int, 8> SplatMask(Shuf->getMask().begin(),
Shuf->getMask().end());
SmallVector<int, 8> SplatMask(Shuf->getMask());
for (int &Idx : SplatMask) {
if (Idx < 0)
continue; // Passthrough sentinel indices.
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3577,7 +3577,7 @@ SDValue DAGTypeLegalizer::SoftPromoteHalfOp_ATOMIC_STORE(SDNode *N,

SDValue DAGTypeLegalizer::SoftPromoteHalfOp_STACKMAP(SDNode *N, unsigned OpNo) {
assert(OpNo > 1); // Because the first two arguments are guaranteed legal.
SmallVector<SDValue> NewOps(N->ops().begin(), N->ops().end());
SmallVector<SDValue> NewOps(N->ops());
SDValue Op = N->getOperand(OpNo);
NewOps[OpNo] = GetSoftPromotedHalf(Op);
SDValue NewNode =
Expand All @@ -3592,7 +3592,7 @@ SDValue DAGTypeLegalizer::SoftPromoteHalfOp_STACKMAP(SDNode *N, unsigned OpNo) {
SDValue DAGTypeLegalizer::SoftPromoteHalfOp_PATCHPOINT(SDNode *N,
unsigned OpNo) {
assert(OpNo >= 7);
SmallVector<SDValue> NewOps(N->ops().begin(), N->ops().end());
SmallVector<SDValue> NewOps(N->ops());
SDValue Op = N->getOperand(OpNo);
NewOps[OpNo] = GetSoftPromotedHalf(Op);
SDValue NewNode =
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2704,7 +2704,7 @@ SDValue DAGTypeLegalizer::PromoteIntOp_SET_ROUNDING(SDNode *N) {

SDValue DAGTypeLegalizer::PromoteIntOp_STACKMAP(SDNode *N, unsigned OpNo) {
assert(OpNo > 1); // Because the first two arguments are guaranteed legal.
SmallVector<SDValue> NewOps(N->ops().begin(), N->ops().end());
SmallVector<SDValue> NewOps(N->ops());
SDValue Operand = N->getOperand(OpNo);
EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), Operand.getValueType());
NewOps[OpNo] = DAG.getNode(ISD::ANY_EXTEND, SDLoc(N), NVT, Operand);
Expand All @@ -2713,7 +2713,7 @@ SDValue DAGTypeLegalizer::PromoteIntOp_STACKMAP(SDNode *N, unsigned OpNo) {

SDValue DAGTypeLegalizer::PromoteIntOp_PATCHPOINT(SDNode *N, unsigned OpNo) {
assert(OpNo >= 7);
SmallVector<SDValue> NewOps(N->ops().begin(), N->ops().end());
SmallVector<SDValue> NewOps(N->ops());
SDValue Operand = N->getOperand(OpNo);
EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), Operand.getValueType());
NewOps[OpNo] = DAG.getNode(ISD::ANY_EXTEND, SDLoc(N), NVT, Operand);
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10032,7 +10032,7 @@ SDValue SelectionDAG::getNode(unsigned Opcode, const SDLoc &DL, EVT VT,

// Copy from an SDUse array into an SDValue array for use with
// the regular getNode logic.
SmallVector<SDValue, 8> NewOps(Ops.begin(), Ops.end());
SmallVector<SDValue, 8> NewOps(Ops);
return getNode(Opcode, DL, VT, NewOps);
}

Expand Down
3 changes: 1 addition & 2 deletions llvm/lib/CodeGen/ShrinkWrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -440,8 +440,7 @@ static bool
isSaveReachableThroughClean(const MachineBasicBlock *SavePoint,
ArrayRef<MachineBasicBlock *> CleanPreds) {
DenseSet<const MachineBasicBlock *> Visited;
SmallVector<MachineBasicBlock *, 4> Worklist(CleanPreds.begin(),
CleanPreds.end());
SmallVector<MachineBasicBlock *, 4> Worklist(CleanPreds);
while (!Worklist.empty()) {
MachineBasicBlock *CleanBB = Worklist.pop_back_val();
if (CleanBB == SavePoint)
Expand Down
Loading