Skip to content

Commit cfc7402

Browse files
[llvm] Use drop_begin (NFC)
1 parent ffa5c3a commit cfc7402

File tree

8 files changed

+23
-28
lines changed

8 files changed

+23
-28
lines changed

llvm/lib/CodeGen/BranchFolding.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1198,14 +1198,13 @@ bool BranchFolder::OptimizeBranches(MachineFunction &MF) {
11981198
// Renumbering blocks alters EH scope membership, recalculate it.
11991199
EHScopeMembership = getEHScopeMembership(MF);
12001200

1201-
for (MachineFunction::iterator I = std::next(MF.begin()), E = MF.end();
1202-
I != E; ) {
1203-
MachineBasicBlock *MBB = &*I++;
1204-
MadeChange |= OptimizeBlock(MBB);
1201+
for (MachineBasicBlock &MBB :
1202+
llvm::make_early_inc_range(llvm::drop_begin(MF))) {
1203+
MadeChange |= OptimizeBlock(&MBB);
12051204

12061205
// If it is dead, remove it.
1207-
if (MBB->pred_empty()) {
1208-
RemoveDeadBlock(MBB);
1206+
if (MBB.pred_empty()) {
1207+
RemoveDeadBlock(&MBB);
12091208
MadeChange = true;
12101209
++NumDeadBlocks;
12111210
}

llvm/lib/CodeGen/TailDuplicator.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -279,18 +279,17 @@ bool TailDuplicator::tailDuplicateBlocks() {
279279
VerifyPHIs(*MF, true);
280280
}
281281

282-
for (MachineFunction::iterator I = ++MF->begin(), E = MF->end(); I != E;) {
283-
MachineBasicBlock *MBB = &*I++;
284-
282+
for (MachineBasicBlock &MBB :
283+
llvm::make_early_inc_range(llvm::drop_begin(*MF))) {
285284
if (NumTails == TailDupLimit)
286285
break;
287286

288-
bool IsSimple = isSimpleBB(MBB);
287+
bool IsSimple = isSimpleBB(&MBB);
289288

290-
if (!shouldTailDuplicate(IsSimple, *MBB))
289+
if (!shouldTailDuplicate(IsSimple, MBB))
291290
continue;
292291

293-
MadeChange |= tailDuplicateAndUpdate(IsSimple, MBB, nullptr);
292+
MadeChange |= tailDuplicateAndUpdate(IsSimple, &MBB, nullptr);
294293
}
295294

296295
if (PreRegAlloc && TailDupVerify)

llvm/lib/Target/AVR/AVRFrameLowering.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,8 @@ void AVRFrameLowering::emitPrologue(MachineFunction &MF,
111111
.setMIFlag(MachineInstr::FrameSetup);
112112

113113
// Mark the FramePtr as live-in in every block except the entry.
114-
for (MachineFunction::iterator I = std::next(MF.begin()), E = MF.end();
115-
I != E; ++I) {
116-
I->addLiveIn(AVR::R29R28);
114+
for (MachineBasicBlock &MBBJ : llvm::drop_begin(MF)) {
115+
MBBJ.addLiveIn(AVR::R29R28);
117116
}
118117

119118
if (!FrameSize) {

llvm/lib/Target/MSP430/MSP430FrameLowering.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,8 @@ void MSP430FrameLowering::emitPrologue(MachineFunction &MF,
7171
.addReg(MSP430::SP);
7272

7373
// Mark the FramePtr as live-in in every block except the entry.
74-
for (MachineFunction::iterator I = std::next(MF.begin()), E = MF.end();
75-
I != E; ++I)
76-
I->addLiveIn(MSP430::R4);
74+
for (MachineBasicBlock &MBBJ : llvm::drop_begin(MF))
75+
MBBJ.addLiveIn(MSP430::R4);
7776

7877
} else
7978
NumBytes = StackSize - MSP430FI->getCalleeSavedFrameSize();

llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -566,8 +566,8 @@ void SystemZELFFrameLowering::emitPrologue(MachineFunction &MF,
566566
// Mark the FramePtr as live at the beginning of every block except
567567
// the entry block. (We'll have marked R11 as live on entry when
568568
// saving the GPRs.)
569-
for (auto I = std::next(MF.begin()), E = MF.end(); I != E; ++I)
570-
I->addLiveIn(SystemZ::R11D);
569+
for (MachineBasicBlock &MBBJ : llvm::drop_begin(MF))
570+
MBBJ.addLiveIn(SystemZ::R11D);
571571
}
572572

573573
// Skip over the FPR/VR saves.

llvm/lib/TextAPI/TextStub.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,9 +1121,9 @@ TextAPIReader::get(MemoryBufferRef InputBuffer) {
11211121
auto File = std::unique_ptr<InterfaceFile>(
11221122
const_cast<InterfaceFile *>(Files.front()));
11231123

1124-
for (auto Iter = std::next(Files.begin()); Iter != Files.end(); ++Iter)
1124+
for (const InterfaceFile *FI : llvm::drop_begin(Files))
11251125
File->addDocument(
1126-
std::shared_ptr<InterfaceFile>(const_cast<InterfaceFile *>(*Iter)));
1126+
std::shared_ptr<InterfaceFile>(const_cast<InterfaceFile *>(FI)));
11271127

11281128
if (YAMLIn.error())
11291129
return make_error<StringError>(Ctx.ErrorMessage, YAMLIn.error());

llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1623,11 +1623,10 @@ struct DSEState {
16231623

16241624
// Find the common post-dominator of all killing blocks.
16251625
BasicBlock *CommonPred = *KillingBlocks.begin();
1626-
for (auto I = std::next(KillingBlocks.begin()), E = KillingBlocks.end();
1627-
I != E; I++) {
1626+
for (BasicBlock *BB : llvm::drop_begin(KillingBlocks)) {
16281627
if (!CommonPred)
16291628
break;
1630-
CommonPred = PDT.findNearestCommonDominator(CommonPred, *I);
1629+
CommonPred = PDT.findNearestCommonDominator(CommonPred, BB);
16311630
}
16321631

16331632
// If CommonPred is in the set of killing blocks, just check if it

llvm/utils/TableGen/CodeGenRegisters.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1624,9 +1624,9 @@ static void computeUberSets(std::vector<UberRegSet> &UberSets,
16241624
assert(USetID && "register number 0 is invalid");
16251625

16261626
AllocatableRegs.insert((*Regs.begin())->EnumValue);
1627-
for (auto I = std::next(Regs.begin()), E = Regs.end(); I != E; ++I) {
1628-
AllocatableRegs.insert((*I)->EnumValue);
1629-
UberSetIDs.join(USetID, (*I)->EnumValue);
1627+
for (const CodeGenRegister *CGR : llvm::drop_begin(Regs)) {
1628+
AllocatableRegs.insert(CGR->EnumValue);
1629+
UberSetIDs.join(USetID, CGR->EnumValue);
16301630
}
16311631
}
16321632
// Combine non-allocatable regs.

0 commit comments

Comments
 (0)