[llvm] cba40c4 - [llvm] Use MachineBasicBlock::{successors,predecessors} (NFC)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 9 07:11:24 PST 2021
Author: Kazu Hirata
Date: 2021-11-09T07:11:14-08:00
New Revision: cba40c4edec83a830145cb50f344d289ee331720
URL: https://github.com/llvm/llvm-project/commit/cba40c4edec83a830145cb50f344d289ee331720
DIFF: https://github.com/llvm/llvm-project/commit/cba40c4edec83a830145cb50f344d289ee331720.diff
LOG: [llvm] Use MachineBasicBlock::{successors,predecessors} (NFC)
Added:
Modified:
llvm/lib/CodeGen/MIRSampleProfile.cpp
llvm/lib/CodeGen/MachineBasicBlock.cpp
llvm/lib/Target/Lanai/LanaiInstrInfo.cpp
llvm/lib/Target/Mips/MipsDelaySlotFiller.cpp
llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/MIRSampleProfile.cpp b/llvm/lib/CodeGen/MIRSampleProfile.cpp
index d4abc4af6a2e1..90ecc6fc68fc5 100644
--- a/llvm/lib/CodeGen/MIRSampleProfile.cpp
+++ b/llvm/lib/CodeGen/MIRSampleProfile.cpp
@@ -169,10 +169,7 @@ void MIRProfileLoader::setBranchProbs(MachineFunction &F) {
const MachineBasicBlock *EC = EquivalenceClass[BB];
uint64_t BBWeight = BlockWeights[EC];
uint64_t SumEdgeWeight = 0;
- for (MachineBasicBlock::succ_iterator SI = BB->succ_begin(),
- SE = BB->succ_end();
- SI != SE; ++SI) {
- MachineBasicBlock *Succ = *SI;
+ for (MachineBasicBlock *Succ : BB->successors()) {
Edge E = std::make_pair(BB, Succ);
SumEdgeWeight += EdgeWeights[E];
}
diff --git a/llvm/lib/CodeGen/MachineBasicBlock.cpp b/llvm/lib/CodeGen/MachineBasicBlock.cpp
index 2a6cd19d368b9..0cc42ef82d7a6 100644
--- a/llvm/lib/CodeGen/MachineBasicBlock.cpp
+++ b/llvm/lib/CodeGen/MachineBasicBlock.cpp
@@ -281,8 +281,8 @@ MachineBasicBlock::getLastNonDebugInstr(bool SkipPseudoOp) {
}
bool MachineBasicBlock::hasEHPadSuccessor() const {
- for (const_succ_iterator I = succ_begin(), E = succ_end(); I != E; ++I)
- if ((*I)->isEHPad())
+ for (const MachineBasicBlock *Succ : successors())
+ if (Succ->isEHPad())
return true;
return false;
}
diff --git a/llvm/lib/Target/Lanai/LanaiInstrInfo.cpp b/llvm/lib/Target/Lanai/LanaiInstrInfo.cpp
index dc2a9ed1aca33..21d035c7ee9c7 100644
--- a/llvm/lib/Target/Lanai/LanaiInstrInfo.cpp
+++ b/llvm/lib/Target/Lanai/LanaiInstrInfo.cpp
@@ -419,10 +419,8 @@ bool LanaiInstrInfo::optimizeCompareInstr(
// live-out. If it is live-out, do not optimize.
if (!isSafe) {
MachineBasicBlock *MBB = CmpInstr.getParent();
- for (MachineBasicBlock::succ_iterator SI = MBB->succ_begin(),
- SE = MBB->succ_end();
- SI != SE; ++SI)
- if ((*SI)->isLiveIn(Lanai::SR))
+ for (const MachineBasicBlock *Succ : MBB->successors())
+ if (Succ->isLiveIn(Lanai::SR))
return false;
}
diff --git a/llvm/lib/Target/Mips/MipsDelaySlotFiller.cpp b/llvm/lib/Target/Mips/MipsDelaySlotFiller.cpp
index 797d812043059..3ff8bcfa7f36d 100644
--- a/llvm/lib/Target/Mips/MipsDelaySlotFiller.cpp
+++ b/llvm/lib/Target/Mips/MipsDelaySlotFiller.cpp
@@ -401,10 +401,9 @@ void RegDefsUses::setUnallocatableRegs(const MachineFunction &MF) {
void RegDefsUses::addLiveOut(const MachineBasicBlock &MBB,
const MachineBasicBlock &SuccBB) {
- for (MachineBasicBlock::const_succ_iterator SI = MBB.succ_begin(),
- SE = MBB.succ_end(); SI != SE; ++SI)
- if (*SI != &SuccBB)
- for (const auto &LI : (*SI)->liveins())
+ for (const MachineBasicBlock *S : MBB.successors())
+ if (S != &SuccBB)
+ for (const auto &LI : S->liveins())
Uses.set(LI.PhysReg);
}
diff --git a/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp b/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
index 90d2794feb1e6..27931a7dfe480 100644
--- a/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
+++ b/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
@@ -7183,8 +7183,8 @@ static bool checkCCKill(MachineInstr &MI, MachineBasicBlock *MBB) {
// If we hit the end of the block, check whether CC is live into a
// successor.
if (miI == MBB->end()) {
- for (auto SI = MBB->succ_begin(), SE = MBB->succ_end(); SI != SE; ++SI)
- if ((*SI)->isLiveIn(SystemZ::CC))
+ for (const MachineBasicBlock *Succ : MBB->successors())
+ if (Succ->isLiveIn(SystemZ::CC))
return false;
}
More information about the llvm-commits
mailing list