Skip to content

Commit 34d4827

Browse files
[llvm] Initialize SmallVector with ranges (NFC) (#100948)
1 parent dfdef2c commit 34d4827

File tree

7 files changed

+9
-24
lines changed

7 files changed

+9
-24
lines changed

llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2426,9 +2426,7 @@ bool InstrRefBasedLDV::mlocJoin(
24262426
// as its predecessors. If a PHI is placed, test to see whether it's now a
24272427
// redundant PHI that we can eliminate.
24282428

2429-
SmallVector<const MachineBasicBlock *, 8> BlockOrders;
2430-
for (auto *Pred : MBB.predecessors())
2431-
BlockOrders.push_back(Pred);
2429+
SmallVector<const MachineBasicBlock *, 8> BlockOrders(MBB.predecessors());
24322430

24332431
// Visit predecessors in RPOT order.
24342432
auto Cmp = [&](const MachineBasicBlock *A, const MachineBasicBlock *B) {
@@ -3268,9 +3266,7 @@ void InstrRefBasedLDV::buildVLocValueMap(
32683266
bool InLocsChanged =
32693267
vlocJoin(*MBB, LiveOutIdx, BlocksToExplore, *LiveIn);
32703268

3271-
SmallVector<const MachineBasicBlock *, 8> Preds;
3272-
for (const auto *Pred : MBB->predecessors())
3273-
Preds.push_back(Pred);
3269+
SmallVector<const MachineBasicBlock *, 8> Preds(MBB->predecessors());
32743270

32753271
// If this block's live-in value is a VPHI, try to pick a machine-value
32763272
// for it. This makes the machine-value available and propagated

llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1246,9 +1246,7 @@ void SelectionDAGBuilder::visitDbgInfo(const Instruction &I) {
12461246
SmallVector<Value *> Values(It->Values.location_ops());
12471247
if (!handleDebugValue(Values, Var, It->Expr, It->DL, SDNodeOrder,
12481248
It->Values.hasArgList())) {
1249-
SmallVector<Value *, 4> Vals;
1250-
for (Value *V : It->Values.location_ops())
1251-
Vals.push_back(V);
1249+
SmallVector<Value *, 4> Vals(It->Values.location_ops());
12521250
addDanglingDebugInfo(Vals,
12531251
FnVarLocs->getDILocalVariable(It->VariableID),
12541252
It->Expr, Vals.size() > 1, It->DL, SDNodeOrder);

llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,9 +260,7 @@ void MCJIT::finalizeObject() {
260260

261261
// Generate code for module is going to move objects out of the 'added' list,
262262
// so we need to copy that out before using it:
263-
SmallVector<Module*, 16> ModsToAdd;
264-
for (auto *M : OwnedModules.added())
265-
ModsToAdd.push_back(M);
263+
SmallVector<Module *, 16> ModsToAdd(OwnedModules.added());
266264

267265
for (auto *M : ModsToAdd)
268266
generateCodeForModule(M);

llvm/lib/IR/BasicBlock.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -626,9 +626,7 @@ BasicBlock *BasicBlock::splitBasicBlockBefore(iterator I, const Twine &BBName) {
626626
// to reflect that the incoming branches will be from the New block and not
627627
// from predecessors of the 'this' block.
628628
// Save predecessors to separate vector before modifying them.
629-
SmallVector<BasicBlock *, 4> Predecessors;
630-
for (BasicBlock *Pred : predecessors(this))
631-
Predecessors.push_back(Pred);
629+
SmallVector<BasicBlock *, 4> Predecessors(predecessors(this));
632630
for (BasicBlock *Pred : Predecessors) {
633631
Instruction *TI = Pred->getTerminator();
634632
TI->replaceSuccessorWith(this, New);

llvm/lib/Target/PowerPC/PPCGenScalarMASSEntries.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,7 @@ bool PPCGenScalarMASSEntries::runOnModule(Module &M) {
123123
// The call to createScalarMASSCall() invalidates the iterator over users
124124
// upon replacing the users. Precomputing the current list of users allows
125125
// us to replace all the call sites.
126-
SmallVector<User *, 4> TheUsers;
127-
for (auto *User : Func.users())
128-
TheUsers.push_back(User);
126+
SmallVector<User *, 4> TheUsers(Func.users());
129127

130128
for (auto *User : TheUsers)
131129
if (auto *CI = dyn_cast_or_null<CallInst>(User)) {

llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,7 @@ class DFAJumpThreading {
149149
unfoldSelectInstrs(DominatorTree *DT,
150150
const SmallVector<SelectInstToUnfold, 4> &SelectInsts) {
151151
DomTreeUpdater DTU(DT, DomTreeUpdater::UpdateStrategy::Eager);
152-
SmallVector<SelectInstToUnfold, 4> Stack;
153-
for (SelectInstToUnfold SIToUnfold : SelectInsts)
154-
Stack.push_back(SIToUnfold);
152+
SmallVector<SelectInstToUnfold, 4> Stack(SelectInsts);
155153

156154
while (!Stack.empty()) {
157155
SelectInstToUnfold SIToUnfold = Stack.pop_back_val();

llvm/lib/Transforms/Utils/ValueMapper.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -565,9 +565,8 @@ void Mapper::remapDbgRecord(DbgRecord &DR) {
565565
}
566566

567567
// Find Value operands and remap those.
568-
SmallVector<Value *, 4> Vals, NewVals;
569-
for (Value *Val : V.location_ops())
570-
Vals.push_back(Val);
568+
SmallVector<Value *, 4> Vals(V.location_ops());
569+
SmallVector<Value *, 4> NewVals;
571570
for (Value *Val : Vals)
572571
NewVals.push_back(mapValue(Val));
573572

0 commit comments

Comments
 (0)