Skip to content

Commit

Permalink
[CodeGen] Use range-based for loops (NFC) (#98706)
Browse files Browse the repository at this point in the history
  • Loading branch information
kazutakahirata authored Jul 13, 2024
1 parent a4f8705 commit 66cd2e0
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 27 deletions.
16 changes: 8 additions & 8 deletions llvm/lib/CodeGen/MachinePipeliner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -999,8 +999,8 @@ void SwingSchedulerDAG::updatePhiDependences() {
RemoveDeps.push_back(PI);
}
}
for (int i = 0, e = RemoveDeps.size(); i != e; ++i)
I.removePred(RemoveDeps[i]);
for (const SDep &D : RemoveDeps)
I.removePred(D);
}
}

Expand Down Expand Up @@ -1041,18 +1041,18 @@ void SwingSchedulerDAG::changeDependences() {
for (const SDep &P : I.Preds)
if (P.getSUnit() == DefSU)
Deps.push_back(P);
for (int i = 0, e = Deps.size(); i != e; i++) {
Topo.RemovePred(&I, Deps[i].getSUnit());
I.removePred(Deps[i]);
for (const SDep &D : Deps) {
Topo.RemovePred(&I, D.getSUnit());
I.removePred(D);
}
// Remove the chain dependence between the instructions.
Deps.clear();
for (auto &P : LastSU->Preds)
if (P.getSUnit() == &I && P.getKind() == SDep::Order)
Deps.push_back(P);
for (int i = 0, e = Deps.size(); i != e; i++) {
Topo.RemovePred(LastSU, Deps[i].getSUnit());
LastSU->removePred(Deps[i]);
for (const SDep &D : Deps) {
Topo.RemovePred(LastSU, D.getSUnit());
LastSU->removePred(D);
}

// Add a dependence between the new instruction and the instruction
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/CodeGen/RegAllocGreedy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1664,8 +1664,8 @@ unsigned RAGreedy::tryLocalSplit(const LiveInterval &VirtReg,

// Remove any gaps with regmask clobbers.
if (Matrix->checkRegMaskInterference(VirtReg, PhysReg))
for (unsigned I = 0, E = RegMaskGaps.size(); I != E; ++I)
GapWeight[RegMaskGaps[I]] = huge_valf;
for (unsigned Gap : RegMaskGaps)
GapWeight[Gap] = huge_valf;

// Try to find the best sequence of gaps to close.
// The new spill weight must be larger than any gap interference.
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/CodeGen/SelectOptimize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1071,8 +1071,8 @@ void SelectOptimizeImpl::getExclBackwardsSlice(Instruction *I,
Slice.push(II);

// Explore all the operands of the current instruction to expand the slice.
for (unsigned k = 0; k < II->getNumOperands(); ++k)
if (auto *OpI = dyn_cast<Instruction>(II->getOperand(k)))
for (Value *Op : II->operand_values())
if (auto *OpI = dyn_cast<Instruction>(Op))
Worklist.push(OpI);
}
}
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20544,8 +20544,8 @@ bool DAGCombiner::checkMergeStoreCandidatesForDependencies(
// * (Op 3) -> Represents the pre or post-indexing offset (or undef for
// non-indexed stores). Not constant on all targets (e.g. ARM)
// and so can participate in a cycle.
for (unsigned j = 0; j < N->getNumOperands(); ++j)
Worklist.push_back(N->getOperand(j).getNode());
for (const SDValue &Op : N->op_values())
Worklist.push_back(Op.getNode());
}
// Search through DAG. We can stop early if we find a store node.
for (unsigned i = 0; i < NumStores; ++i)
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/CodeGen/SelectionDAG/InstrEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1182,8 +1182,8 @@ EmitMachineNode(SDNode *Node, bool IsClone, bool IsCloned,
append_range(UsedRegs, MCID.implicit_uses());
// In addition to declared implicit uses, we must also check for
// direct RegisterSDNode operands.
for (unsigned i = 0, e = F->getNumOperands(); i != e; ++i)
if (RegisterSDNode *R = dyn_cast<RegisterSDNode>(F->getOperand(i))) {
for (const SDValue &Op : F->op_values())
if (RegisterSDNode *R = dyn_cast<RegisterSDNode>(Op)) {
Register Reg = R->getReg();
if (Reg.isPhysical())
UsedRegs.push_back(Reg);
Expand Down
4 changes: 1 addition & 3 deletions llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5608,10 +5608,8 @@ void SelectionDAGLegalize::PromoteNode(SDNode *Node) {
MVT MidVT = getPromotedVectorElementType(TLI, EltVT, NewEltVT);

SmallVector<SDValue, 8> NewOps;
for (unsigned I = 0, E = Node->getNumOperands(); I != E; ++I) {
SDValue Op = Node->getOperand(I);
for (const SDValue &Op : Node->op_values())
NewOps.push_back(DAG.getNode(ISD::BITCAST, SDLoc(Op), MidVT, Op));
}

SDLoc SL(Node);
SDValue Concat =
Expand Down
13 changes: 5 additions & 8 deletions llvm/lib/CodeGen/StackSlotColoring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,13 +224,10 @@ void StackSlotColoring::ScanForSpillSlotRefs(MachineFunction &MF) {
li.incrementWeight(
LiveIntervals::getSpillWeight(false, true, MBFI, MI));
}
for (MachineInstr::mmo_iterator MMOI = MI.memoperands_begin(),
EE = MI.memoperands_end();
MMOI != EE; ++MMOI) {
MachineMemOperand *MMO = *MMOI;
for (MachineMemOperand *MMO : MI.memoperands()) {
if (const FixedStackPseudoSourceValue *FSV =
dyn_cast_or_null<FixedStackPseudoSourceValue>(
MMO->getPseudoValue())) {
dyn_cast_or_null<FixedStackPseudoSourceValue>(
MMO->getPseudoValue())) {
int FI = FSV->getFrameIndex();
if (FI >= 0)
SSRefs[FI].push_back(MMO);
Expand Down Expand Up @@ -552,8 +549,8 @@ bool StackSlotColoring::runOnMachineFunction(MachineFunction &MF) {
Next = -1;

SSIntervals.clear();
for (unsigned i = 0, e = SSRefs.size(); i != e; ++i)
SSRefs[i].clear();
for (auto &RefMMOs : SSRefs)
RefMMOs.clear();
SSRefs.clear();
OrigAlignments.clear();
OrigSizes.clear();
Expand Down

0 comments on commit 66cd2e0

Please sign in to comment.