Skip to content

Commit

Permalink
Use llvm::drop_begin and llvm::drop_end (NFC)
Browse files Browse the repository at this point in the history
  • Loading branch information
kazutakahirata committed Sep 23, 2023
1 parent 3bca659 commit ce8c228
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 13 deletions.
3 changes: 1 addition & 2 deletions clang/lib/AST/TextNodeDumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1901,8 +1901,7 @@ void TextNodeDumper::VisitFunctionDecl(const FunctionDecl *D) {
auto Overrides = MD->overridden_methods();
OS << "Overrides: [ ";
dumpOverride(*Overrides.begin());
for (const auto *Override :
llvm::make_range(Overrides.begin() + 1, Overrides.end())) {
for (const auto *Override : llvm::drop_begin(Overrides)) {
OS << ", ";
dumpOverride(Override);
}
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/CodeGen/GlobalISel/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1173,7 +1173,7 @@ llvm::getVectorSplat(const MachineInstr &MI, const MachineRegisterInfo &MRI) {
if (auto Splat = getIConstantSplatSExtVal(MI, MRI))
return RegOrConstant(*Splat);
auto Reg = MI.getOperand(1).getReg();
if (any_of(make_range(MI.operands_begin() + 2, MI.operands_end()),
if (any_of(drop_begin(MI.operands(), 2),
[&Reg](const MachineOperand &Op) { return Op.getReg() != Reg; }))
return std::nullopt;
return RegOrConstant(Reg);
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/CodeGen/MachineCopyPropagation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1147,11 +1147,11 @@ void MachineCopyPropagation::EliminateSpillageCopies(MachineBasicBlock &MBB) {
return;

// If violate property#2, we don't fold the chain.
for (const MachineInstr *Spill : make_range(SC.begin() + 1, SC.end()))
for (const MachineInstr *Spill : drop_begin(SC))
if (CopySourceInvalid.count(Spill))
return;

for (const MachineInstr *Reload : make_range(RC.begin(), RC.end() - 1))
for (const MachineInstr *Reload : drop_end(RC))
if (CopySourceInvalid.count(Reload))
return;

Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/IR/Instructions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ Value *PHINode::removeIncomingValue(unsigned Idx, bool DeletePHIIfEmpty) {
// clients might not expect this to happen. The code as it is thrashes the
// use/def lists, which is kinda lame.
std::copy(op_begin() + Idx + 1, op_end(), op_begin() + Idx);
copyIncomingBlocks(make_range(block_begin() + Idx + 1, block_end()), Idx);
copyIncomingBlocks(drop_begin(blocks(), Idx + 1), Idx);

// Nuke the last value.
Op<-1>().set(nullptr);
Expand Down
3 changes: 1 addition & 2 deletions llvm/lib/MCA/Stages/EntryStage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ llvm::Error EntryStage::cycleResume() {

llvm::Error EntryStage::cycleEnd() {
// Find the first instruction which hasn't been retired.
auto Range =
make_range(Instructions.begin() + NumRetired, Instructions.end());
auto Range = drop_begin(Instructions, NumRetired);
auto It = find_if(Range, [](const std::unique_ptr<Instruction> &I) {
return !I->isRetired();
});
Expand Down
8 changes: 3 additions & 5 deletions llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5517,11 +5517,9 @@ bool AArch64InstructionSelector::tryOptBuildVecToSubregToReg(
const RegisterBank &DstRB = *RBI.getRegBank(Dst, MRI, TRI);
if (EltRB != DstRB)
return false;
if (any_of(make_range(I.operands_begin() + 2, I.operands_end()),
[&MRI](const MachineOperand &Op) {
return !getOpcodeDef(TargetOpcode::G_IMPLICIT_DEF, Op.getReg(),
MRI);
}))
if (any_of(drop_begin(I.operands(), 2), [&MRI](const MachineOperand &Op) {
return !getOpcodeDef(TargetOpcode::G_IMPLICIT_DEF, Op.getReg(), MRI);
}))
return false;
unsigned SubReg;
const TargetRegisterClass *EltRC = getRegClassForTypeOnBank(EltTy, EltRB);
Expand Down

0 comments on commit ce8c228

Please sign in to comment.