[llvm] Use MachineBasicBlock::{successors,predecessors} (NFC)

This commit is contained in:
Kazu Hirata 2021-11-09 07:11:13 -08:00
parent b2d9258474
commit cba40c4ede
5 changed files with 10 additions and 16 deletions

View File

@ -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];
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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;
}