Skip to content

Commit 587d2c1

Browse files
kazutakahiratarlavaee
authored andcommitted
[Target] Use range-based for loops (NFC) (llvm#146198)
1 parent a75ab39 commit 587d2c1

File tree

6 files changed

+21
-28
lines changed

6 files changed

+21
-28
lines changed

llvm/lib/Target/AMDGPU/SIShrinkInstructions.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -842,10 +842,7 @@ bool SIShrinkInstructions::run(MachineFunction &MF) {
842842

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

845-
for (MachineFunction::iterator BI = MF.begin(), BE = MF.end();
846-
BI != BE; ++BI) {
847-
848-
MachineBasicBlock &MBB = *BI;
845+
for (MachineBasicBlock &MBB : MF) {
849846
MachineBasicBlock::iterator I, Next;
850847
for (I = MBB.begin(); I != MBB.end(); I = Next) {
851848
Next = std::next(I);

llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3126,8 +3126,8 @@ bool ARMBaseInstrInfo::optimizeCompareInstr(
31263126
// Modify the condition code of operands in OperandsToUpdate.
31273127
// Since we have SUB(r1, r2) and CMP(r2, r1), the condition code needs to
31283128
// be changed from r2 > r1 to r1 < r2, from r2 < r1 to r1 > r2, etc.
3129-
for (unsigned i = 0, e = OperandsToUpdate.size(); i < e; i++)
3130-
OperandsToUpdate[i].first->setImm(OperandsToUpdate[i].second);
3129+
for (auto &[MO, Cond] : OperandsToUpdate)
3130+
MO->setImm(Cond);
31313131

31323132
MI->clearRegisterDeads(ARM::CPSR);
31333133

llvm/lib/Target/ARM/ARMConstantIslandPass.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -476,8 +476,8 @@ bool ARMConstantIslands::runOnMachineFunction(MachineFunction &mf) {
476476

477477
LLVM_DEBUG(dbgs() << "Beginning BR iteration #" << NoBRIters << '\n');
478478
bool BRChange = false;
479-
for (unsigned i = 0, e = ImmBranches.size(); i != e; ++i)
480-
BRChange |= fixupImmediateBr(ImmBranches[i]);
479+
for (ImmBranch &Br : ImmBranches)
480+
BRChange |= fixupImmediateBr(Br);
481481
if (BRChange && ++NoBRIters > 30)
482482
report_fatal_error("Branch Fix Up pass failed to converge!");
483483
LLVM_DEBUG(dumpBBs());

llvm/lib/Target/ARM/ARMFrameLowering.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1701,8 +1701,8 @@ void ARMFrameLowering::emitPushInst(MachineBasicBlock &MBB,
17011701
.addReg(ARM::SP)
17021702
.setMIFlags(MachineInstr::FrameSetup)
17031703
.add(predOps(ARMCC::AL));
1704-
for (unsigned i = 0, e = Regs.size(); i < e; ++i)
1705-
MIB.addReg(Regs[i].first, getKillRegState(Regs[i].second));
1704+
for (const auto [Reg, Kill] : Regs)
1705+
MIB.addReg(Reg, getKillRegState(Kill));
17061706
} else if (Regs.size() == 1) {
17071707
BuildMI(MBB, MI, DL, TII.get(StrOpc), ARM::SP)
17081708
.addReg(Regs[0].first, getKillRegState(Regs[0].second))

llvm/lib/Target/ARM/ARMISelLowering.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2766,9 +2766,8 @@ ARMTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
27662766
// Build a sequence of copy-to-reg nodes chained together with token chain
27672767
// and flag operands which copy the outgoing args into the appropriate regs.
27682768
SDValue InGlue;
2769-
for (unsigned i = 0, e = RegsToPass.size(); i != e; ++i) {
2770-
Chain = DAG.getCopyToReg(Chain, dl, RegsToPass[i].first,
2771-
RegsToPass[i].second, InGlue);
2769+
for (const auto [Reg, N] : RegsToPass) {
2770+
Chain = DAG.getCopyToReg(Chain, dl, Reg, N, InGlue);
27722771
InGlue = Chain.getValue(1);
27732772
}
27742773

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

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

29592957
// Add a register mask operand representing the call-preserved registers.
29602958
const uint32_t *Mask;

llvm/lib/Target/X86/X86ISelLoweringCall.cpp

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1929,9 +1929,9 @@ SDValue X86TargetLowering::LowerFormalArguments(
19291929
}
19301930

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

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

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

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

26172615
if (CallingConv::PreserveNone == CallConv)
2618-
for (unsigned I = 0, E = Outs.size(); I != E; ++I) {
2619-
if (Outs[I].Flags.isSwiftSelf() || Outs[I].Flags.isSwiftAsync() ||
2620-
Outs[I].Flags.isSwiftError()) {
2616+
for (const ISD::OutputArg &Out : Outs) {
2617+
if (Out.Flags.isSwiftSelf() || Out.Flags.isSwiftAsync() ||
2618+
Out.Flags.isSwiftError()) {
26212619
errorUnsupported(DAG, dl,
26222620
"Swift attributes can't be used with preserve_none");
26232621
break;

0 commit comments

Comments
 (0)