Use drop_begin (NFC)

This commit is contained in:
Kazu Hirata 2022-07-15 23:58:11 -07:00
parent 58753dea15
commit 5605a1eedd
4 changed files with 11 additions and 14 deletions

View File

@ -1213,8 +1213,8 @@ void SystemZXPLINKFrameLowering::emitPrologue(MachineFunction &MF,
// Mark the FramePtr as live at the beginning of every block except
// the entry block. (We'll have marked R8 as live on entry when
// saving the GPRs.)
for (auto I = std::next(MF.begin()), E = MF.end(); I != E; ++I)
I->addLiveIn(Regs.getFramePointerRegister());
for (MachineBasicBlock &B : llvm::drop_begin(MF))
B.addLiveIn(Regs.getFramePointerRegister());
}
}

View File

@ -645,8 +645,7 @@ static LogicalResult printOperation(CppEmitter &emitter,
}
// Declare variables for basic block arguments.
for (auto it = std::next(blocks.begin()); it != blocks.end(); ++it) {
Block &block = *it;
for (Block &block : llvm::drop_begin(blocks)) {
for (BlockArgument &arg : block.getArguments()) {
if (emitter.hasValueInScope(arg))
return functionOp.emitOpError(" block argument #")

View File

@ -485,17 +485,15 @@ void mlir::LLVM::detail::connectPHINodes(Region &region,
const ModuleTranslation &state) {
// Skip the first block, it cannot be branched to and its arguments correspond
// to the arguments of the LLVM function.
for (auto it = std::next(region.begin()), eit = region.end(); it != eit;
++it) {
Block *bb = &*it;
llvm::BasicBlock *llvmBB = state.lookupBlock(bb);
for (Block &bb : llvm::drop_begin(region)) {
llvm::BasicBlock *llvmBB = state.lookupBlock(&bb);
auto phis = llvmBB->phis();
auto numArguments = bb->getNumArguments();
auto numArguments = bb.getNumArguments();
assert(numArguments == std::distance(phis.begin(), phis.end()));
for (auto &numberedPhiNode : llvm::enumerate(phis)) {
auto &phiNode = numberedPhiNode.value();
unsigned index = numberedPhiNode.index();
for (auto *pred : bb->getPredecessors()) {
for (auto *pred : bb.getPredecessors()) {
// Find the LLVM IR block that contains the converted terminator
// instruction and use it in the PHI node. Note that this block is not
// necessarily the same as state.lookupBlock(pred), some operations
@ -504,9 +502,9 @@ void mlir::LLVM::detail::connectPHINodes(Region &region,
llvm::Instruction *terminator =
state.lookupBranch(pred->getTerminator());
assert(terminator && "missing the mapping for a terminator");
phiNode.addIncoming(
state.lookupValue(getPHISourceValue(bb, pred, numArguments, index)),
terminator->getParent());
phiNode.addIncoming(state.lookupValue(getPHISourceValue(
&bb, pred, numArguments, index)),
terminator->getParent());
}
}
}

View File

@ -420,7 +420,7 @@ LogicalResult Serializer::processLoopOp(spirv::LoopOp loopOp) {
// properly. We don't need to assign for the entry block, which is just for
// satisfying MLIR region's structural requirement.
auto &body = loopOp.body();
for (Block &block : llvm::make_range(std::next(body.begin(), 1), body.end()))
for (Block &block : llvm::drop_begin(body))
getOrCreateBlockID(&block);
auto *headerBlock = loopOp.getHeaderBlock();