Skip to content

[Target] Use range-based for loops (NFC) #146198

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
5 changes: 1 addition & 4 deletions llvm/lib/Target/AMDGPU/SIShrinkInstructions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -842,10 +842,7 @@ bool SIShrinkInstructions::run(MachineFunction &MF) {

unsigned VCCReg = ST->isWave32() ? AMDGPU::VCC_LO : AMDGPU::VCC;

for (MachineFunction::iterator BI = MF.begin(), BE = MF.end();
BI != BE; ++BI) {

MachineBasicBlock &MBB = *BI;
for (MachineBasicBlock &MBB : MF) {
MachineBasicBlock::iterator I, Next;
for (I = MBB.begin(); I != MBB.end(); I = Next) {
Next = std::next(I);
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3126,8 +3126,8 @@ bool ARMBaseInstrInfo::optimizeCompareInstr(
// Modify the condition code of operands in OperandsToUpdate.
// Since we have SUB(r1, r2) and CMP(r2, r1), the condition code needs to
// be changed from r2 > r1 to r1 < r2, from r2 < r1 to r1 > r2, etc.
for (unsigned i = 0, e = OperandsToUpdate.size(); i < e; i++)
OperandsToUpdate[i].first->setImm(OperandsToUpdate[i].second);
for (auto &[MO, Cond] : OperandsToUpdate)
MO->setImm(Cond);

MI->clearRegisterDeads(ARM::CPSR);

Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Target/ARM/ARMConstantIslandPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -476,8 +476,8 @@ bool ARMConstantIslands::runOnMachineFunction(MachineFunction &mf) {

LLVM_DEBUG(dbgs() << "Beginning BR iteration #" << NoBRIters << '\n');
bool BRChange = false;
for (unsigned i = 0, e = ImmBranches.size(); i != e; ++i)
BRChange |= fixupImmediateBr(ImmBranches[i]);
for (ImmBranch &Br : ImmBranches)
BRChange |= fixupImmediateBr(Br);
if (BRChange && ++NoBRIters > 30)
report_fatal_error("Branch Fix Up pass failed to converge!");
LLVM_DEBUG(dumpBBs());
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Target/ARM/ARMFrameLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1701,8 +1701,8 @@ void ARMFrameLowering::emitPushInst(MachineBasicBlock &MBB,
.addReg(ARM::SP)
.setMIFlags(MachineInstr::FrameSetup)
.add(predOps(ARMCC::AL));
for (unsigned i = 0, e = Regs.size(); i < e; ++i)
MIB.addReg(Regs[i].first, getKillRegState(Regs[i].second));
for (const auto [Reg, Kill] : Regs)
MIB.addReg(Reg, getKillRegState(Kill));
} else if (Regs.size() == 1) {
BuildMI(MBB, MI, DL, TII.get(StrOpc), ARM::SP)
.addReg(Regs[0].first, getKillRegState(Regs[0].second))
Expand Down
10 changes: 4 additions & 6 deletions llvm/lib/Target/ARM/ARMISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2766,9 +2766,8 @@ ARMTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
// Build a sequence of copy-to-reg nodes chained together with token chain
// and flag operands which copy the outgoing args into the appropriate regs.
SDValue InGlue;
for (unsigned i = 0, e = RegsToPass.size(); i != e; ++i) {
Chain = DAG.getCopyToReg(Chain, dl, RegsToPass[i].first,
RegsToPass[i].second, InGlue);
for (const auto [Reg, N] : RegsToPass) {
Chain = DAG.getCopyToReg(Chain, dl, Reg, N, InGlue);
InGlue = Chain.getValue(1);
}

Expand Down Expand Up @@ -2952,9 +2951,8 @@ ARMTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,

// Add argument registers to the end of the list so that they are known live
// into the call.
for (unsigned i = 0, e = RegsToPass.size(); i != e; ++i)
Ops.push_back(DAG.getRegister(RegsToPass[i].first,
RegsToPass[i].second.getValueType()));
for (const auto [Reg, N] : RegsToPass)
Ops.push_back(DAG.getRegister(Reg, N.getValueType()));

// Add a register mask operand representing the call-preserved registers.
const uint32_t *Mask;
Expand Down
22 changes: 10 additions & 12 deletions llvm/lib/Target/X86/X86ISelLoweringCall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1929,9 +1929,9 @@ SDValue X86TargetLowering::LowerFormalArguments(
}

if (CallingConv::PreserveNone == CallConv)
for (unsigned I = 0, E = Ins.size(); I != E; ++I) {
if (Ins[I].Flags.isSwiftSelf() || Ins[I].Flags.isSwiftAsync() ||
Ins[I].Flags.isSwiftError()) {
for (const ISD::InputArg &In : Ins) {
if (In.Flags.isSwiftSelf() || In.Flags.isSwiftAsync() ||
In.Flags.isSwiftError()) {
errorUnsupported(DAG, dl,
"Swift attributes can't be used with preserve_none");
break;
Expand Down Expand Up @@ -2421,9 +2421,8 @@ X86TargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
// Build a sequence of copy-to-reg nodes chained together with token chain
// and glue operands which copy the outgoing args into registers.
SDValue InGlue;
for (unsigned i = 0, e = RegsToPass.size(); i != e; ++i) {
Chain = DAG.getCopyToReg(Chain, dl, RegsToPass[i].first,
RegsToPass[i].second, InGlue);
for (const auto [Reg, N] : RegsToPass) {
Chain = DAG.getCopyToReg(Chain, dl, Reg, N, InGlue);
InGlue = Chain.getValue(1);
}

Expand Down Expand Up @@ -2462,9 +2461,8 @@ X86TargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,

// Add argument registers to the end of the list so that they are known live
// into the call.
for (unsigned i = 0, e = RegsToPass.size(); i != e; ++i)
Ops.push_back(DAG.getRegister(RegsToPass[i].first,
RegsToPass[i].second.getValueType()));
for (const auto [Reg, N] : RegsToPass)
Ops.push_back(DAG.getRegister(Reg, N.getValueType()));

// Add a register mask operand representing the call-preserved registers.
const uint32_t *Mask = [&]() {
Expand Down Expand Up @@ -2615,9 +2613,9 @@ X86TargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
}

if (CallingConv::PreserveNone == CallConv)
for (unsigned I = 0, E = Outs.size(); I != E; ++I) {
if (Outs[I].Flags.isSwiftSelf() || Outs[I].Flags.isSwiftAsync() ||
Outs[I].Flags.isSwiftError()) {
for (const ISD::OutputArg &Out : Outs) {
if (Out.Flags.isSwiftSelf() || Out.Flags.isSwiftAsync() ||
Out.Flags.isSwiftError()) {
errorUnsupported(DAG, dl,
"Swift attributes can't be used with preserve_none");
break;
Expand Down
Loading