Skip to content

Commit 2efcbe2

Browse files
[llvm] Use llvm::drop_begin (NFC)
1 parent 9bcc0d1 commit 2efcbe2

File tree

11 files changed

+16
-19
lines changed

11 files changed

+16
-19
lines changed

llvm/lib/Analysis/LazyCallGraph.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,7 @@ LazyCallGraph::RefSCC::switchInternalEdgeToRef(Node &SourceN, Node &TargetN) {
866866
PendingSCCStack.clear();
867867
while (!DFSStack.empty())
868868
OldSCC.Nodes.push_back(DFSStack.pop_back_val().first);
869-
for (Node &N : make_range(OldSCC.begin() + OldSize, OldSCC.end())) {
869+
for (Node &N : drop_begin(OldSCC, OldSize)) {
870870
N.DFSNumber = N.LowLink = -1;
871871
G->SCCMap[&N] = &OldSCC;
872872
}

llvm/lib/Analysis/ModuleSummaryAnalysis.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ static void addVCallToSet(DevirtCallSite Call, GlobalValue::GUID Guid,
145145
SetVector<FunctionSummary::ConstVCall> &ConstVCalls) {
146146
std::vector<uint64_t> Args;
147147
// Start from the second argument to skip the "this" pointer.
148-
for (auto &Arg : make_range(Call.CB.arg_begin() + 1, Call.CB.arg_end())) {
148+
for (auto &Arg : drop_begin(Call.CB.args(), 1)) {
149149
auto *CI = dyn_cast<ConstantInt>(Arg);
150150
if (!CI || CI->getBitWidth() > 64) {
151151
VCalls.insert({Guid, Call.Offset});

llvm/lib/Analysis/VFABIDemangling.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -290,9 +290,9 @@ bool verifyAllVectorsHaveSameWidth(FunctionType *Signature) {
290290

291291
assert(VecTys.size() > 1 && "Invalid number of elements.");
292292
const ElementCount EC = VecTys[0]->getElementCount();
293-
return llvm::all_of(
294-
llvm::make_range(VecTys.begin() + 1, VecTys.end()),
295-
[&EC](VectorType *VTy) { return (EC == VTy->getElementCount()); });
293+
return llvm::all_of(llvm::drop_begin(VecTys, 1), [&EC](VectorType *VTy) {
294+
return (EC == VTy->getElementCount());
295+
});
296296
}
297297

298298
#endif // NDEBUG

llvm/lib/CodeGen/CodeGenPrepare.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ bool CodeGenPrepare::eliminateFallThrough(Function &F) {
661661
// Use a temporary array to avoid iterator being invalidated when
662662
// deleting blocks.
663663
SmallVector<WeakTrackingVH, 16> Blocks;
664-
for (auto &Block : llvm::make_range(std::next(F.begin()), F.end()))
664+
for (auto &Block : llvm::drop_begin(F, 1))
665665
Blocks.push_back(&Block);
666666

667667
SmallSet<WeakTrackingVH, 16> Preds;
@@ -747,7 +747,7 @@ bool CodeGenPrepare::eliminateMostlyEmptyBlocks(Function &F) {
747747
// as we remove them.
748748
// Note that this intentionally skips the entry block.
749749
SmallVector<WeakTrackingVH, 16> Blocks;
750-
for (auto &Block : llvm::make_range(std::next(F.begin()), F.end()))
750+
for (auto &Block : llvm::drop_begin(F, 1))
751751
Blocks.push_back(&Block);
752752

753753
for (auto &Block : Blocks) {

llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCInstrInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ HexagonMCInstrInfo::bundleInstructions(MCInstrInfo const &MCII,
110110
iterator_range<MCInst::const_iterator>
111111
HexagonMCInstrInfo::bundleInstructions(MCInst const &MCI) {
112112
assert(isBundle(MCI));
113-
return make_range(MCI.begin() + bundleInstructionsOffset, MCI.end());
113+
return drop_begin(MCI, bundleInstructionsOffset);
114114
}
115115

116116
size_t HexagonMCInstrInfo::bundleSize(MCInst const &MCI) {

llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -977,8 +977,7 @@ WebAssemblyTargetLowering::LowerCall(CallLoweringInfo &CLI,
977977
/*isSS=*/false);
978978
unsigned ValNo = 0;
979979
SmallVector<SDValue, 8> Chains;
980-
for (SDValue Arg :
981-
make_range(OutVals.begin() + NumFixedArgs, OutVals.end())) {
980+
for (SDValue Arg : drop_begin(OutVals, NumFixedArgs)) {
982981
assert(ArgLocs[ValNo].getValNo() == ValNo &&
983982
"ArgLocs should remain in order and only hold varargs args");
984983
unsigned Offset = ArgLocs[ValNo++].getLocMemOffset();

llvm/lib/Target/X86/X86MCInstLower.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1334,7 +1334,7 @@ void X86AsmPrinter::LowerPATCHABLE_OP(const MachineInstr &MI,
13341334

13351335
MCInst MCI;
13361336
MCI.setOpcode(Opcode);
1337-
for (auto &MO : make_range(MI.operands_begin() + 2, MI.operands_end()))
1337+
for (auto &MO : drop_begin(MI.operands(), 2))
13381338
if (auto MaybeOperand = MCIL.LowerMachineOperand(&MI, MO))
13391339
MCI.addOperand(MaybeOperand.getValue());
13401340

@@ -1710,7 +1710,7 @@ void X86AsmPrinter::LowerPATCHABLE_RET(const MachineInstr &MI,
17101710
unsigned OpCode = MI.getOperand(0).getImm();
17111711
MCInst Ret;
17121712
Ret.setOpcode(OpCode);
1713-
for (auto &MO : make_range(MI.operands_begin() + 1, MI.operands_end()))
1713+
for (auto &MO : drop_begin(MI.operands(), 1))
17141714
if (auto MaybeOperand = MCIL.LowerMachineOperand(&MI, MO))
17151715
Ret.addOperand(MaybeOperand.getValue());
17161716
OutStreamer->emitInstruction(Ret, getSubtargetInfo());
@@ -1749,7 +1749,7 @@ void X86AsmPrinter::LowerPATCHABLE_TAIL_CALL(const MachineInstr &MI,
17491749
// Before emitting the instruction, add a comment to indicate that this is
17501750
// indeed a tail call.
17511751
OutStreamer->AddComment("TAILCALL");
1752-
for (auto &MO : make_range(MI.operands_begin() + 1, MI.operands_end()))
1752+
for (auto &MO : drop_begin(MI.operands(), 1))
17531753
if (auto MaybeOperand = MCIL.LowerMachineOperand(&MI, MO))
17541754
TC.addOperand(MaybeOperand.getValue());
17551755
OutStreamer->emitInstruction(TC, getSubtargetInfo());

llvm/lib/Transforms/IPO/OpenMPOpt.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -739,8 +739,7 @@ struct OpenMPOpt {
739739
<< ore::NV("OpenMPParallelMergeFront",
740740
MergableCIs.front()->getDebugLoc())
741741
<< " merged with parallel regions at ";
742-
for (auto *CI :
743-
llvm::make_range(MergableCIs.begin() + 1, MergableCIs.end())) {
742+
for (auto *CI : llvm::drop_begin(MergableCIs, 1)) {
744743
OR << ore::NV("OpenMPParallelMerge", CI->getDebugLoc());
745744
if (CI != MergableCIs.back())
746745
OR << ", ";

llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ void splitAndWriteThinLTOBitcode(
261261
if (!RT || RT->getBitWidth() > 64 || F->arg_empty() ||
262262
!F->arg_begin()->use_empty())
263263
return;
264-
for (auto &Arg : make_range(std::next(F->arg_begin()), F->arg_end())) {
264+
for (auto &Arg : drop_begin(F->args(), 1)) {
265265
auto *ArgT = dyn_cast<IntegerType>(Arg.getType());
266266
if (!ArgT || ArgT->getBitWidth() > 64)
267267
return;

llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ CallSiteInfo &VTableSlotInfo::findCallSiteInfo(CallBase &CB) {
470470
auto *CBType = dyn_cast<IntegerType>(CB.getType());
471471
if (!CBType || CBType->getBitWidth() > 64 || CB.arg_empty())
472472
return CSInfo;
473-
for (auto &&Arg : make_range(CB.arg_begin() + 1, CB.arg_end())) {
473+
for (auto &&Arg : drop_begin(CB.args(), 1)) {
474474
auto *CI = dyn_cast<ConstantInt>(Arg);
475475
if (!CI || CI->getBitWidth() > 64)
476476
return CSInfo;

llvm/tools/llvm-xray/xray-stacks.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -456,8 +456,7 @@ class StackTrie {
456456
int Level = 0;
457457
OS << formatv("{0,-5} {1,-60} {2,+12} {3,+16}\n", "lvl", "function",
458458
"count", "sum");
459-
for (auto *F :
460-
reverse(make_range(CurrentStack.begin() + 1, CurrentStack.end()))) {
459+
for (auto *F : reverse(drop_begin(CurrentStack, 1))) {
461460
auto Sum = std::accumulate(F->ExtraData.IntermediateDurations.begin(),
462461
F->ExtraData.IntermediateDurations.end(), 0LL);
463462
auto FuncId = FN.SymbolOrNumber(F->FuncId);

0 commit comments

Comments
 (0)