Skip to content

Commit bf60217

Browse files
Use drop_begin (NFC)
1 parent 71336d0 commit bf60217

File tree

8 files changed

+30
-38
lines changed

8 files changed

+30
-38
lines changed

bolt/lib/Passes/Inliner.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -288,12 +288,12 @@ Inliner::inlineCall(BinaryBasicBlock &CallerBB,
288288
// Copy basic blocks and maintain a map from their origin.
289289
std::unordered_map<const BinaryBasicBlock *, BinaryBasicBlock *> InlinedBBMap;
290290
InlinedBBMap[&Callee.front()] = FirstInlinedBB;
291-
for (auto BBI = std::next(Callee.begin()); BBI != Callee.end(); ++BBI) {
291+
for (const BinaryBasicBlock &BB : llvm::drop_begin(Callee)) {
292292
BinaryBasicBlock *InlinedBB = CallerFunction.addBasicBlock();
293-
InlinedBBMap[&*BBI] = InlinedBB;
293+
InlinedBBMap[&BB] = InlinedBB;
294294
InlinedBB->setCFIState(FirstInlinedBB->getCFIState());
295295
if (Callee.hasValidProfile())
296-
InlinedBB->setExecutionCount(BBI->getKnownExecutionCount());
296+
InlinedBB->setExecutionCount(BB.getKnownExecutionCount());
297297
else
298298
InlinedBB->setExecutionCount(FirstInlinedBBCount);
299299
}

llvm/lib/Analysis/MustExecute.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,11 @@ void SimpleLoopSafetyInfo::computeLoopSafetyInfo(const Loop *CurLoop) {
5959
// The first block in loopinfo.Blocks is guaranteed to be the header.
6060
assert(Header == *CurLoop->getBlocks().begin() &&
6161
"First block must be header");
62-
for (Loop::block_iterator BB = std::next(CurLoop->block_begin()),
63-
BBE = CurLoop->block_end();
64-
(BB != BBE) && !MayThrow; ++BB)
65-
MayThrow |= !isGuaranteedToTransferExecutionToSuccessor(*BB);
62+
for (const BasicBlock *BB : llvm::drop_begin(CurLoop->blocks())) {
63+
MayThrow |= !isGuaranteedToTransferExecutionToSuccessor(BB);
64+
if (MayThrow)
65+
break;
66+
}
6667

6768
computeBlockColors(CurLoop);
6869
}

llvm/lib/LineEditor/LineEditor.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "llvm/LineEditor/LineEditor.h"
10+
#include "llvm/ADT/STLExtras.h"
1011
#include "llvm/ADT/SmallString.h"
1112
#include "llvm/Config/config.h"
1213
#include "llvm/Support/Path.h"
@@ -37,13 +38,11 @@ std::string LineEditor::ListCompleterConcept::getCommonPrefix(
3738
assert(!Comps.empty());
3839

3940
std::string CommonPrefix = Comps[0].TypedText;
40-
for (std::vector<Completion>::const_iterator I = Comps.begin() + 1,
41-
E = Comps.end();
42-
I != E; ++I) {
43-
size_t Len = std::min(CommonPrefix.size(), I->TypedText.size());
41+
for (const Completion &C : llvm::drop_begin(Comps)) {
42+
size_t Len = std::min(CommonPrefix.size(), C.TypedText.size());
4443
size_t CommonLen = 0;
4544
for (; CommonLen != Len; ++CommonLen) {
46-
if (CommonPrefix[CommonLen] != I->TypedText[CommonLen])
45+
if (CommonPrefix[CommonLen] != C.TypedText[CommonLen])
4746
break;
4847
}
4948
CommonPrefix.resize(CommonLen);

llvm/lib/MC/MCAsmStreamer.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -565,10 +565,8 @@ void MCAsmStreamer::emitAssemblerFlag(MCAssemblerFlag Flag) {
565565
void MCAsmStreamer::emitLinkerOptions(ArrayRef<std::string> Options) {
566566
assert(!Options.empty() && "At least one option is required!");
567567
OS << "\t.linker_option \"" << Options[0] << '"';
568-
for (ArrayRef<std::string>::iterator it = Options.begin() + 1,
569-
ie = Options.end(); it != ie; ++it) {
570-
OS << ", " << '"' << *it << '"';
571-
}
568+
for (const std::string &Opt : llvm::drop_begin(Options))
569+
OS << ", " << '"' << Opt << '"';
572570
EmitEOL();
573571
}
574572

llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,11 +1115,10 @@ void AArch64AsmPrinter::LowerFAULTING_OP(const MachineInstr &FaultingMI) {
11151115
if (DefRegister != (Register)0)
11161116
MI.addOperand(MCOperand::createReg(DefRegister));
11171117

1118-
for (auto I = FaultingMI.operands_begin() + OperandsBeginIdx,
1119-
E = FaultingMI.operands_end();
1120-
I != E; ++I) {
1118+
for (const MachineOperand &MO :
1119+
llvm::drop_begin(FaultingMI.operands(), OperandsBeginIdx)) {
11211120
MCOperand Dest;
1122-
lowerOperand(*I, Dest);
1121+
lowerOperand(MO, Dest);
11231122
MI.addOperand(Dest);
11241123
}
11251124

llvm/lib/Target/X86/X86MCInstLower.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1313,10 +1313,9 @@ void X86AsmPrinter::LowerFAULTING_OP(const MachineInstr &FaultingMI,
13131313
if (DefRegister != X86::NoRegister)
13141314
MI.addOperand(MCOperand::createReg(DefRegister));
13151315

1316-
for (auto I = FaultingMI.operands_begin() + OperandsBeginIdx,
1317-
E = FaultingMI.operands_end();
1318-
I != E; ++I)
1319-
if (auto MaybeOperand = MCIL.LowerMachineOperand(&FaultingMI, *I))
1316+
for (const MachineOperand &MO :
1317+
llvm::drop_begin(FaultingMI.operands(), OperandsBeginIdx))
1318+
if (auto MaybeOperand = MCIL.LowerMachineOperand(&FaultingMI, MO))
13201319
MI.addOperand(*MaybeOperand);
13211320

13221321
OutStreamer->AddComment("on-fault: " + HandlerLabel->getName());

llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4461,11 +4461,9 @@ struct VarArgMIPS64Helper : public VarArgHelper {
44614461
void visitCallBase(CallBase &CB, IRBuilder<> &IRB) override {
44624462
unsigned VAArgOffset = 0;
44634463
const DataLayout &DL = F.getParent()->getDataLayout();
4464-
for (auto ArgIt = CB.arg_begin() + CB.getFunctionType()->getNumParams(),
4465-
End = CB.arg_end();
4466-
ArgIt != End; ++ArgIt) {
4464+
for (Value *A :
4465+
llvm::drop_begin(CB.args(), CB.getFunctionType()->getNumParams())) {
44674466
Triple TargetTriple(F.getParent()->getTargetTriple());
4468-
Value *A = *ArgIt;
44694467
Value *Base;
44704468
uint64_t ArgSize = DL.getTypeAllocSize(A->getType());
44714469
if (TargetTriple.getArch() == Triple::mips64) {

llvm/lib/Transforms/Scalar/LoopDistribute.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -461,16 +461,14 @@ class InstPartitionContainer {
461461
// update PH to point to the newly added preheader.
462462
BasicBlock *TopPH = OrigPH;
463463
unsigned Index = getSize() - 1;
464-
for (auto I = std::next(PartitionContainer.rbegin()),
465-
E = PartitionContainer.rend();
466-
I != E; ++I, --Index, TopPH = NewLoop->getLoopPreheader()) {
467-
auto *Part = &*I;
468-
469-
NewLoop = Part->cloneLoopWithPreheader(TopPH, Pred, Index, LI, DT);
470-
471-
Part->getVMap()[ExitBlock] = TopPH;
472-
Part->remapInstructions();
473-
setNewLoopID(OrigLoopID, Part);
464+
for (auto &Part : llvm::drop_begin(llvm::reverse(PartitionContainer))) {
465+
NewLoop = Part.cloneLoopWithPreheader(TopPH, Pred, Index, LI, DT);
466+
467+
Part.getVMap()[ExitBlock] = TopPH;
468+
Part.remapInstructions();
469+
setNewLoopID(OrigLoopID, &Part);
470+
--Index;
471+
TopPH = NewLoop->getLoopPreheader();
474472
}
475473
Pred->getTerminator()->replaceUsesOfWith(OrigPH, TopPH);
476474

0 commit comments

Comments
 (0)