Skip to content

Commit b38de6c

Browse files
authored
[NFCI][LLVM] Adopt ArrayRef::consume_front() in a few places (#146793)
1 parent 7b517cf commit b38de6c

File tree

5 files changed

+21
-30
lines changed

5 files changed

+21
-30
lines changed

llvm/include/llvm/DebugInfo/CodeView/SymbolRecord.h

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -240,32 +240,28 @@ struct BinaryAnnotationIterator
240240
if (Annotations.empty())
241241
return -1;
242242

243-
uint8_t FirstByte = Annotations.front();
244-
Annotations = Annotations.drop_front();
243+
uint8_t FirstByte = Annotations.consume_front();
245244

246245
if ((FirstByte & 0x80) == 0x00)
247246
return FirstByte;
248247

249248
if (Annotations.empty())
250249
return -1;
251250

252-
uint8_t SecondByte = Annotations.front();
253-
Annotations = Annotations.drop_front();
251+
uint8_t SecondByte = Annotations.consume_front();
254252

255253
if ((FirstByte & 0xC0) == 0x80)
256254
return ((FirstByte & 0x3F) << 8) | SecondByte;
257255

258256
if (Annotations.empty())
259257
return -1;
260258

261-
uint8_t ThirdByte = Annotations.front();
262-
Annotations = Annotations.drop_front();
259+
uint8_t ThirdByte = Annotations.consume_front();
263260

264261
if (Annotations.empty())
265262
return -1;
266263

267-
uint8_t FourthByte = Annotations.front();
268-
Annotations = Annotations.drop_front();
264+
uint8_t FourthByte = Annotations.consume_front();
269265

270266
if ((FirstByte & 0xE0) == 0xC0)
271267
return ((FirstByte & 0x1F) << 24) | (SecondByte << 16) |

llvm/lib/Bitcode/Reader/BitcodeReader.cpp

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7513,11 +7513,9 @@ std::vector<FunctionSummary::ParamAccess>
75137513
ModuleSummaryIndexBitcodeReader::parseParamAccesses(ArrayRef<uint64_t> Record) {
75147514
auto ReadRange = [&]() {
75157515
APInt Lower(FunctionSummary::ParamAccess::RangeWidth,
7516-
BitcodeReader::decodeSignRotatedValue(Record.front()));
7517-
Record = Record.drop_front();
7516+
BitcodeReader::decodeSignRotatedValue(Record.consume_front()));
75187517
APInt Upper(FunctionSummary::ParamAccess::RangeWidth,
7519-
BitcodeReader::decodeSignRotatedValue(Record.front()));
7520-
Record = Record.drop_front();
7518+
BitcodeReader::decodeSignRotatedValue(Record.consume_front()));
75217519
ConstantRange Range{Lower, Upper};
75227520
assert(!Range.isFullSet());
75237521
assert(!Range.isUpperSignWrapped());
@@ -7528,16 +7526,13 @@ ModuleSummaryIndexBitcodeReader::parseParamAccesses(ArrayRef<uint64_t> Record) {
75287526
while (!Record.empty()) {
75297527
PendingParamAccesses.emplace_back();
75307528
FunctionSummary::ParamAccess &ParamAccess = PendingParamAccesses.back();
7531-
ParamAccess.ParamNo = Record.front();
7532-
Record = Record.drop_front();
7529+
ParamAccess.ParamNo = Record.consume_front();
75337530
ParamAccess.Use = ReadRange();
7534-
ParamAccess.Calls.resize(Record.front());
7535-
Record = Record.drop_front();
7531+
ParamAccess.Calls.resize(Record.consume_front());
75367532
for (auto &Call : ParamAccess.Calls) {
7537-
Call.ParamNo = Record.front();
7538-
Record = Record.drop_front();
7539-
Call.Callee = std::get<0>(getValueInfoFromValueId(Record.front()));
7540-
Record = Record.drop_front();
7533+
Call.ParamNo = Record.consume_front();
7534+
Call.Callee =
7535+
std::get<0>(getValueInfoFromValueId(Record.consume_front()));
75417536
Call.Offsets = ReadRange();
75427537
}
75437538
}

llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2085,8 +2085,8 @@ TypeIndex CodeViewDebug::lowerTypeFunction(const DISubroutineType *Ty) {
20852085
ArrayRef<TypeIndex> ArgTypeIndices = {};
20862086
if (!ReturnAndArgTypeIndices.empty()) {
20872087
auto ReturnAndArgTypesRef = ArrayRef(ReturnAndArgTypeIndices);
2088-
ReturnTypeIndex = ReturnAndArgTypesRef.front();
2089-
ArgTypeIndices = ReturnAndArgTypesRef.drop_front();
2088+
ReturnTypeIndex = ReturnAndArgTypesRef.consume_front();
2089+
ArgTypeIndices = ReturnAndArgTypesRef;
20902090
}
20912091

20922092
ArgListRecord ArgListRec(TypeRecordKind::ArgList, ArgTypeIndices);

llvm/lib/CodeGen/MachinePostDominators.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ MachineBasicBlock *MachinePostDominatorTree::findNearestCommonDominator(
9999
ArrayRef<MachineBasicBlock *> Blocks) const {
100100
assert(!Blocks.empty());
101101

102-
MachineBasicBlock *NCD = Blocks.front();
103-
for (MachineBasicBlock *BB : Blocks.drop_front()) {
102+
MachineBasicBlock *NCD = Blocks.consume_front();
103+
for (MachineBasicBlock *BB : Blocks) {
104104
NCD = Base::findNearestCommonDominator(NCD, BB);
105105

106106
// Stop when the root is reached.

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1511,8 +1511,8 @@ static InstructionsState getSameOpcode(ArrayRef<Value *> VL,
15111511
/// \returns true if all of the values in \p VL have the same type or false
15121512
/// otherwise.
15131513
static bool allSameType(ArrayRef<Value *> VL) {
1514-
Type *Ty = VL.front()->getType();
1515-
return all_of(VL.drop_front(), [&](Value *V) { return V->getType() == Ty; });
1514+
Type *Ty = VL.consume_front()->getType();
1515+
return all_of(VL, [&](Value *V) { return V->getType() == Ty; });
15161516
}
15171517

15181518
/// \returns True if in-tree use also needs extract. This refers to
@@ -5567,8 +5567,8 @@ static bool arePointersCompatible(Value *Ptr1, Value *Ptr2,
55675567
/// Calculates minimal alignment as a common alignment.
55685568
template <typename T>
55695569
static Align computeCommonAlignment(ArrayRef<Value *> VL) {
5570-
Align CommonAlignment = cast<T>(VL.front())->getAlign();
5571-
for (Value *V : VL.drop_front())
5570+
Align CommonAlignment = cast<T>(VL.consume_front())->getAlign();
5571+
for (Value *V : VL)
55725572
CommonAlignment = std::min(CommonAlignment, cast<T>(V)->getAlign());
55735573
return CommonAlignment;
55745574
}
@@ -9483,8 +9483,8 @@ class PHIHandler {
94839483
ArrayRef<unsigned> IncomingValues = P.second;
94849484
if (IncomingValues.size() <= 1)
94859485
continue;
9486-
unsigned BasicI = IncomingValues.front();
9487-
for (unsigned I : IncomingValues.drop_front()) {
9486+
unsigned BasicI = IncomingValues.consume_front();
9487+
for (unsigned I : IncomingValues) {
94889488
assert(all_of(enumerate(Operands[I]),
94899489
[&](const auto &Data) {
94909490
return !Data.value() ||

0 commit comments

Comments
 (0)