[llvm] 49e3838 - [llvm] Use make_early_inc_range (NFC)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sun Nov 21 19:24:31 PST 2021
Author: Kazu Hirata
Date: 2021-11-21T19:24:17-08:00
New Revision: 49e3838145dff1ec91c2e67a2cb562775c8d2a08
URL: https://github.com/llvm/llvm-project/commit/49e3838145dff1ec91c2e67a2cb562775c8d2a08
DIFF: https://github.com/llvm/llvm-project/commit/49e3838145dff1ec91c2e67a2cb562775c8d2a08.diff
LOG: [llvm] Use make_early_inc_range (NFC)
Added:
Modified:
llvm/lib/Target/AMDGPU/R600Packetizer.cpp
llvm/lib/Target/Hexagon/HexagonPeephole.cpp
llvm/lib/Target/Lanai/LanaiFrameLowering.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/AMDGPU/R600Packetizer.cpp b/llvm/lib/Target/AMDGPU/R600Packetizer.cpp
index e858bba2983cc..beb0aad86e898 100644
--- a/llvm/lib/Target/AMDGPU/R600Packetizer.cpp
+++ b/llvm/lib/Target/AMDGPU/R600Packetizer.cpp
@@ -343,20 +343,11 @@ bool R600Packetizer::runOnMachineFunction(MachineFunction &Fn) {
// dependence between Insn 0 and Insn 2. This can lead to incorrect
// packetization
//
- for (MachineFunction::iterator MBB = Fn.begin(), MBBe = Fn.end();
- MBB != MBBe; ++MBB) {
- MachineBasicBlock::iterator End = MBB->end();
- MachineBasicBlock::iterator MI = MBB->begin();
- while (MI != End) {
- if (MI->isKill() || MI->getOpcode() == R600::IMPLICIT_DEF ||
- (MI->getOpcode() == R600::CF_ALU && !MI->getOperand(8).getImm())) {
- MachineBasicBlock::iterator DeleteMI = MI;
- ++MI;
- MBB->erase(DeleteMI);
- End = MBB->end();
- continue;
- }
- ++MI;
+ for (MachineBasicBlock &MBB : Fn) {
+ for (MachineInstr &MI : llvm::make_early_inc_range(MBB)) {
+ if (MI.isKill() || MI.getOpcode() == R600::IMPLICIT_DEF ||
+ (MI.getOpcode() == R600::CF_ALU && !MI.getOperand(8).getImm()))
+ MBB.erase(MI);
}
}
diff --git a/llvm/lib/Target/Hexagon/HexagonPeephole.cpp b/llvm/lib/Target/Hexagon/HexagonPeephole.cpp
index fc31139e13ce2..1ff248200572e 100644
--- a/llvm/lib/Target/Hexagon/HexagonPeephole.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonPeephole.cpp
@@ -120,16 +120,12 @@ bool HexagonPeephole::runOnMachineFunction(MachineFunction &MF) {
if (DisableHexagonPeephole) return false;
// Loop over all of the basic blocks.
- for (MachineFunction::iterator MBBb = MF.begin(), MBBe = MF.end();
- MBBb != MBBe; ++MBBb) {
- MachineBasicBlock *MBB = &*MBBb;
+ for (MachineBasicBlock &MBB : MF) {
PeepholeMap.clear();
PeepholeDoubleRegsMap.clear();
// Traverse the basic block.
- for (auto I = MBB->begin(), E = MBB->end(), NextI = I; I != E; I = NextI) {
- NextI = std::next(I);
- MachineInstr &MI = *I;
+ for (MachineInstr &MI : llvm::make_early_inc_range(MBB)) {
// Look for sign extends:
// %170 = SXTW %166
if (!DisableOptSZExt && MI.getOpcode() == Hexagon::A2_sxtw) {
@@ -274,11 +270,11 @@ bool HexagonPeephole::runOnMachineFunction(MachineFunction &MF) {
if (NewOp) {
Register PSrc = MI.getOperand(PR).getReg();
if (unsigned POrig = PeepholeMap.lookup(PSrc)) {
- BuildMI(*MBB, MI.getIterator(), MI.getDebugLoc(),
- QII->get(NewOp), MI.getOperand(0).getReg())
- .addReg(POrig)
- .add(MI.getOperand(S2))
- .add(MI.getOperand(S1));
+ BuildMI(MBB, MI.getIterator(), MI.getDebugLoc(), QII->get(NewOp),
+ MI.getOperand(0).getReg())
+ .addReg(POrig)
+ .add(MI.getOperand(S2))
+ .add(MI.getOperand(S1));
MRI->clearKillFlags(POrig);
MI.eraseFromParent();
}
diff --git a/llvm/lib/Target/Lanai/LanaiFrameLowering.cpp b/llvm/lib/Target/Lanai/LanaiFrameLowering.cpp
index 3a2d5030775e7..3644eafe4353b 100644
--- a/llvm/lib/Target/Lanai/LanaiFrameLowering.cpp
+++ b/llvm/lib/Target/Lanai/LanaiFrameLowering.cpp
@@ -65,17 +65,14 @@ void LanaiFrameLowering::replaceAdjDynAllocPseudo(MachineFunction &MF) const {
*static_cast<const LanaiInstrInfo *>(STI.getInstrInfo());
unsigned MaxCallFrameSize = MF.getFrameInfo().getMaxCallFrameSize();
- for (MachineFunction::iterator MBB = MF.begin(), E = MF.end(); MBB != E;
- ++MBB) {
- MachineBasicBlock::iterator MBBI = MBB->begin();
- while (MBBI != MBB->end()) {
- MachineInstr &MI = *MBBI++;
+ for (MachineBasicBlock &MBB : MF) {
+ for (MachineInstr &MI : llvm::make_early_inc_range(MBB)) {
if (MI.getOpcode() == Lanai::ADJDYNALLOC) {
DebugLoc DL = MI.getDebugLoc();
Register Dst = MI.getOperand(0).getReg();
Register Src = MI.getOperand(1).getReg();
- BuildMI(*MBB, MI, DL, LII.get(Lanai::ADD_I_LO), Dst)
+ BuildMI(MBB, MI, DL, LII.get(Lanai::ADD_I_LO), Dst)
.addReg(Src)
.addImm(MaxCallFrameSize);
MI.eraseFromParent();
More information about the llvm-commits
mailing list