Skip to content

[Transforms] Use range-based for loops (NFC) #98725

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
4 changes: 2 additions & 2 deletions llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5953,8 +5953,8 @@ void LSRInstance::RewriteForPHI(
// formulae will not be implemented completely and some instructions
// will not be eliminated.
if (needUpdateFixups) {
for (size_t LUIdx = 0, NumUses = Uses.size(); LUIdx != NumUses; ++LUIdx)
for (LSRFixup &Fixup : Uses[LUIdx].Fixups)
for (LSRUse &LU : Uses)
for (LSRFixup &Fixup : LU.Fixups)
// If fixup is supposed to rewrite some operand in the phi
// that was just updated, it may be already moved to
// another phi node. Such fixup requires update.
Expand Down
12 changes: 6 additions & 6 deletions llvm/lib/Transforms/Scalar/Reassociate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -596,8 +596,8 @@ void ReassociatePass::RewriteExprTree(BinaryOperator *I,
/// of leaf nodes as inner nodes cannot occur by remembering all of the future
/// leaves and refusing to reuse any of them as inner nodes.
SmallPtrSet<Value*, 8> NotRewritable;
for (unsigned i = 0, e = Ops.size(); i != e; ++i)
NotRewritable.insert(Ops[i].Op);
for (const ValueEntry &Op : Ops)
NotRewritable.insert(Op.Op);

// ExpressionChangedStart - Non-null if the rewritten expression differs from
// the original in some non-trivial way, requiring the clearing of optional
Expand Down Expand Up @@ -762,8 +762,8 @@ void ReassociatePass::RewriteExprTree(BinaryOperator *I,
}

// Throw away any left over nodes from the original expression.
for (unsigned i = 0, e = NodesToRewrite.size(); i != e; ++i)
RedoInsts.insert(NodesToRewrite[i]);
for (BinaryOperator *BO : NodesToRewrite)
RedoInsts.insert(BO);
}

/// Insert instructions before the instruction pointed to by BI,
Expand Down Expand Up @@ -1988,8 +1988,8 @@ void ReassociatePass::EraseInst(Instruction *I) {
I->eraseFromParent();
// Optimize its operands.
SmallPtrSet<Instruction *, 8> Visited; // Detect self-referential nodes.
for (unsigned i = 0, e = Ops.size(); i != e; ++i)
if (Instruction *Op = dyn_cast<Instruction>(Ops[i])) {
for (Value *V : Ops)
if (Instruction *Op = dyn_cast<Instruction>(V)) {
// If this is a node in an expression tree, climb to the expression root
// and add that since that's where optimization actually happens.
unsigned Opcode = Op->getOpcode();
Expand Down
7 changes: 3 additions & 4 deletions llvm/lib/Transforms/Utils/InlineFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1815,10 +1815,9 @@ static void fixupLineNumbers(Function *Fn, Function::iterator FI,

// Iterate over all instructions, updating metadata and debug-info records.
for (; FI != Fn->end(); ++FI) {
for (BasicBlock::iterator BI = FI->begin(), BE = FI->end(); BI != BE;
++BI) {
UpdateInst(*BI);
for (DbgRecord &DVR : BI->getDbgRecordRange()) {
for (Instruction &I : *FI) {
UpdateInst(I);
for (DbgRecord &DVR : I.getDbgRecordRange()) {
UpdateDVR(&DVR);
}
}
Expand Down
Loading