SmallVector<MachineInstr *, 4> SplitPoints;
char State = BI.InitialState;
- auto II = MBB.getFirstNonPHI(), IE = MBB.end();
- while (II != IE) {
- auto Next = std::next(II);
- MachineInstr &MI = *II;
-
+ for (MachineInstr &MI : llvm::make_early_inc_range(
+ llvm::make_range(MBB.getFirstNonPHI(), MBB.end()))) {
if (StateTransition.count(&MI))
State = StateTransition[&MI];
}
if (SplitPoint)
SplitPoints.push_back(SplitPoint);
-
- II = Next;
}
// Perform splitting after instruction scan to simplify iteration.
MachineBasicBlock::iterator MI,
const TargetInstrInfo &TII, Register FP) {
// Iterate through the BB until we hit a call instruction or we reach the end.
- for (auto I = MI, E = MBB.end(); I != E && !I->isCall();) {
- MachineBasicBlock::iterator NextMI = std::next(I);
- MachineInstr &MI = *I;
- unsigned Opcode = I->getOpcode();
+ for (MachineInstr &MI :
+ llvm::make_early_inc_range(llvm::make_range(MI, MBB.end()))) {
+ if (MI.isCall())
+ break;
+
+ unsigned Opcode = MI.getOpcode();
// Only care of pseudo store instructions where SP is the base pointer.
- if (Opcode != AVR::STDSPQRr && Opcode != AVR::STDWSPQRr) {
- I = NextMI;
+ if (Opcode != AVR::STDSPQRr && Opcode != AVR::STDWSPQRr)
continue;
- }
assert(MI.getOperand(0).getReg() == AVR::SP &&
"Invalid register, should be SP!");
MI.setDesc(TII.get(STOpc));
MI.getOperand(0).setReg(FP);
-
- I = NextMI;
}
}
// Go through all uses of %1 as in %1 = ADD_rr %2, %3
const MachineOperand Op0 = Inst->getOperand(0);
- auto Begin = MRI->use_begin(Op0.getReg()), End = MRI->use_end();
- decltype(End) NextI;
- for (auto I = Begin; I != End; I = NextI) {
- NextI = std::next(I);
+ for (MachineOperand &MO :
+ llvm::make_early_inc_range(MRI->use_operands(Op0.getReg()))) {
// The candidate needs to have a unique definition.
- if (!MRI->getUniqueVRegDef(I->getReg()))
+ if (!MRI->getUniqueVRegDef(MO.getReg()))
continue;
- MachineInstr *DefInst = I->getParent();
+ MachineInstr *DefInst = MO.getParent();
unsigned Opcode = DefInst->getOpcode();
unsigned COREOp;
if (Opcode == BPF::LDB || Opcode == BPF::LDH || Opcode == BPF::LDW ||
Opcode == BPF::STD || Opcode == BPF::STB32 || Opcode == BPF::STH32 ||
Opcode == BPF::STW32) {
const MachineOperand &Opnd = DefInst->getOperand(0);
- if (Opnd.isReg() && Opnd.getReg() == I->getReg())
+ if (Opnd.isReg() && Opnd.getReg() == MO.getReg())
continue;
}
// erase instructions during rewriting, so this needs to be delayed until
// now.
for (MachineBasicBlock &B : MF) {
- MachineBasicBlock::iterator I = B.begin(), E = B.end();
- while (I != E) {
- auto Next = std::next(I);
- if (I->isBranch() && !InstrExec.count(&*I))
- B.erase(I);
- I = Next;
- }
+ for (MachineInstr &MI : llvm::make_early_inc_range(B))
+ if (MI.isBranch() && !InstrExec.count(&MI))
+ B.erase(&MI);
}
return Changed;
}
// dependence between Insn 0 and Insn 2. This can lead to incorrect
// packetization
for (MachineBasicBlock &MB : MF) {
- auto End = MB.end();
- auto MI = MB.begin();
- while (MI != End) {
- auto NextI = std::next(MI);
- if (MI->isKill()) {
- MB.erase(MI);
- End = MB.end();
- }
- MI = NextI;
- }
+ for (MachineInstr &MI : llvm::make_early_inc_range(MB))
+ if (MI.isKill())
+ MB.erase(&MI);
}
// TinyCore with Duplexes: Translate to big-instructions.
// nothing to do.
if (MF.size() < 2)
return Changed;
-
- // We can't use a range-based for loop due to clobbering the iterator.
- for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E;) {
- MachineBasicBlock &B = *I++;
+
+ for (MachineBasicBlock &B : llvm::make_early_inc_range(MF))
Changed |= processBlock(B);
- }
return Changed;
}
bool Changed = false;
- for (MachineFunction::iterator I = MF.begin(); I != MF.end();) {
- MachineBasicBlock &B = *I++;
+ for (MachineBasicBlock &B : llvm::make_early_inc_range(MF))
if (processBlock(B))
Changed = true;
- }
return Changed;
}
bool runOnMachineFunction(MachineFunction &MF) override {
bool Changed = false;
- for (MachineFunction::iterator I = MF.begin(); I != MF.end();) {
- MachineBasicBlock &B = *I++;
+ for (MachineBasicBlock &B : llvm::make_early_inc_range(MF))
if (processBlock(B))
Changed = true;
- }
return Changed;
}
bool Changed = false;
- for (MachineFunction::iterator I = MF.begin(); I != MF.end();) {
- MachineBasicBlock &B = *I++;
+ for (MachineBasicBlock &B : llvm::make_early_inc_range(MF))
if (processBlock(B))
Changed = true;
- }
return Changed;
}
char PPCVSXCopy::ID = 0;
FunctionPass*
llvm::createPPCVSXCopyPass() { return new PPCVSXCopy(); }
-
if (DisableVSXFMAMutate)
return Changed;
- for (MachineFunction::iterator I = MF.begin(); I != MF.end();) {
- MachineBasicBlock &B = *I++;
+ for (MachineBasicBlock &B : llvm::make_early_inc_range(MF))
if (processBlock(B))
Changed = true;
- }
return Changed;
}
}
// Transfer any debug instructions inside the CMOV sequence to the sunk block.
- auto DbgEnd = MachineBasicBlock::iterator(LastCMOV);
- auto DbgIt = MachineBasicBlock::iterator(MI);
- while (DbgIt != DbgEnd) {
- auto Next = std::next(DbgIt);
- if (DbgIt->isDebugInstr())
- SinkMBB->push_back(DbgIt->removeFromParent());
- DbgIt = Next;
- }
+ auto DbgRange = llvm::make_range(MachineBasicBlock::iterator(MI),
+ MachineBasicBlock::iterator(LastCMOV));
+ for (MachineInstr &MI : llvm::make_early_inc_range(DbgRange))
+ if (MI.isDebugInstr())
+ SinkMBB->push_back(MI.removeFromParent());
// Transfer the remainder of ThisMBB and its successor edges to SinkMBB.
SinkMBB->splice(SinkMBB->end(), ThisMBB,
Value *ResAMX =
Builder.CreateBitCast(ResVec, Type::getX86_AMXTy(Builder.getContext()));
// Delete TileDP intrinsic and do some clean-up.
- for (auto UI = TileDP->use_begin(), UE = TileDP->use_end(); UI != UE;) {
- Instruction *I = cast<Instruction>((UI++)->getUser());
+ for (Use &U : llvm::make_early_inc_range(TileDP->uses())) {
+ Instruction *I = cast<Instruction>(U.getUser());
Value *Vec;
if (match(I, m_BitCast(m_Value(Vec)))) {
I->replaceAllUsesWith(ResVec);
Value *ResAMX =
Builder.CreateBitCast(ResVec, Type::getX86_AMXTy(Builder.getContext()));
// Delete tileloadd6 intrinsic and do some clean-up
- for (auto UI = TileLoadStore->use_begin(), UE = TileLoadStore->use_end();
- UI != UE;) {
- Instruction *I = cast<Instruction>((UI++)->getUser());
+ for (Use &U : llvm::make_early_inc_range(TileLoadStore->uses())) {
+ Instruction *I = cast<Instruction>(U.getUser());
Value *Vec;
if (match(I, m_BitCast(m_Value(Vec)))) {
I->replaceAllUsesWith(ResVec);
Col2Row.clear();
for (BasicBlock *BB : post_order(&Func)) {
- for (BasicBlock::reverse_iterator II = BB->rbegin(), IE = BB->rend();
- II != IE;) {
- Instruction &Inst = *II++;
+ for (Instruction &Inst : llvm::make_early_inc_range(llvm::reverse(*BB))) {
auto *Bitcast = dyn_cast<BitCastInst>(&Inst);
if (!Bitcast)
continue;
bool Changed = false;
for (MachineBasicBlock &MBB : MF) {
- for (MachineBasicBlock::iterator MII = MBB.begin(), MIE = MBB.end();
- MII != MIE;) {
- MachineInstr &MI = *MII++;
+ for (MachineInstr &MI : llvm::make_early_inc_range(MBB)) {
if (!MI.isCopy())
continue;
MachineOperand &DstMO = MI.getOperand(0);
// isReplaceable function.
Register FirstVReg = First.getOperand(0).getReg();
Register LastVReg = Last.getOperand(0).getReg();
- for (auto UI = MRI->use_begin(LastVReg), UE = MRI->use_end();
- UI != UE;) {
- MachineOperand &MO = *UI++;
+ for (MachineOperand &MO :
+ llvm::make_early_inc_range(MRI->use_operands(LastVReg))) {
MachineInstr &MI = *MO.getParent();
if (MI.isDebugValue()) {