Skip to content

[llvm] Initialize SmallVector with ranges (NFC) #100948

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
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
8 changes: 2 additions & 6 deletions llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2426,9 +2426,7 @@ bool InstrRefBasedLDV::mlocJoin(
// as its predecessors. If a PHI is placed, test to see whether it's now a
// redundant PHI that we can eliminate.

SmallVector<const MachineBasicBlock *, 8> BlockOrders;
for (auto *Pred : MBB.predecessors())
BlockOrders.push_back(Pred);
SmallVector<const MachineBasicBlock *, 8> BlockOrders(MBB.predecessors());

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

SmallVector<const MachineBasicBlock *, 8> Preds;
for (const auto *Pred : MBB->predecessors())
Preds.push_back(Pred);
SmallVector<const MachineBasicBlock *, 8> Preds(MBB->predecessors());

// If this block's live-in value is a VPHI, try to pick a machine-value
// for it. This makes the machine-value available and propagated
Expand Down
4 changes: 1 addition & 3 deletions llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1246,9 +1246,7 @@ void SelectionDAGBuilder::visitDbgInfo(const Instruction &I) {
SmallVector<Value *> Values(It->Values.location_ops());
if (!handleDebugValue(Values, Var, It->Expr, It->DL, SDNodeOrder,
It->Values.hasArgList())) {
SmallVector<Value *, 4> Vals;
for (Value *V : It->Values.location_ops())
Vals.push_back(V);
SmallVector<Value *, 4> Vals(It->Values.location_ops());
addDanglingDebugInfo(Vals,
FnVarLocs->getDILocalVariable(It->VariableID),
It->Expr, Vals.size() > 1, It->DL, SDNodeOrder);
Expand Down
4 changes: 1 addition & 3 deletions llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,7 @@ void MCJIT::finalizeObject() {

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

for (auto *M : ModsToAdd)
generateCodeForModule(M);
Expand Down
4 changes: 1 addition & 3 deletions llvm/lib/IR/BasicBlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -626,9 +626,7 @@ BasicBlock *BasicBlock::splitBasicBlockBefore(iterator I, const Twine &BBName) {
// to reflect that the incoming branches will be from the New block and not
// from predecessors of the 'this' block.
// Save predecessors to separate vector before modifying them.
SmallVector<BasicBlock *, 4> Predecessors;
for (BasicBlock *Pred : predecessors(this))
Predecessors.push_back(Pred);
SmallVector<BasicBlock *, 4> Predecessors(predecessors(this));
for (BasicBlock *Pred : Predecessors) {
Instruction *TI = Pred->getTerminator();
TI->replaceSuccessorWith(this, New);
Expand Down
4 changes: 1 addition & 3 deletions llvm/lib/Target/PowerPC/PPCGenScalarMASSEntries.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,7 @@ bool PPCGenScalarMASSEntries::runOnModule(Module &M) {
// The call to createScalarMASSCall() invalidates the iterator over users
// upon replacing the users. Precomputing the current list of users allows
// us to replace all the call sites.
SmallVector<User *, 4> TheUsers;
for (auto *User : Func.users())
TheUsers.push_back(User);
SmallVector<User *, 4> TheUsers(Func.users());

for (auto *User : TheUsers)
if (auto *CI = dyn_cast_or_null<CallInst>(User)) {
Expand Down
4 changes: 1 addition & 3 deletions llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,7 @@ class DFAJumpThreading {
unfoldSelectInstrs(DominatorTree *DT,
const SmallVector<SelectInstToUnfold, 4> &SelectInsts) {
DomTreeUpdater DTU(DT, DomTreeUpdater::UpdateStrategy::Eager);
SmallVector<SelectInstToUnfold, 4> Stack;
for (SelectInstToUnfold SIToUnfold : SelectInsts)
Stack.push_back(SIToUnfold);
SmallVector<SelectInstToUnfold, 4> Stack(SelectInsts);

while (!Stack.empty()) {
SelectInstToUnfold SIToUnfold = Stack.pop_back_val();
Expand Down
5 changes: 2 additions & 3 deletions llvm/lib/Transforms/Utils/ValueMapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -565,9 +565,8 @@ void Mapper::remapDbgRecord(DbgRecord &DR) {
}

// Find Value operands and remap those.
SmallVector<Value *, 4> Vals, NewVals;
for (Value *Val : V.location_ops())
Vals.push_back(Val);
SmallVector<Value *, 4> Vals(V.location_ops());
SmallVector<Value *, 4> NewVals;
for (Value *Val : Vals)
NewVals.push_back(mapValue(Val));

Expand Down
Loading