Skip to content

Commit 41ef318

Browse files
[ARM, X86] Use MachineBasicBlock::{predecessors,successors} (NFC)
1 parent eb1c7c1 commit 41ef318

File tree

8 files changed

+20
-39
lines changed

8 files changed

+20
-39
lines changed

llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3265,9 +3265,8 @@ bool ARMBaseInstrInfo::optimizeCompareInstr(
32653265
// live-out. If it is live-out, do not optimize.
32663266
if (!isSafe) {
32673267
MachineBasicBlock *MBB = CmpInstr.getParent();
3268-
for (MachineBasicBlock::succ_iterator SI = MBB->succ_begin(),
3269-
SE = MBB->succ_end(); SI != SE; ++SI)
3270-
if ((*SI)->isLiveIn(ARM::CPSR))
3268+
for (MachineBasicBlock *Succ : MBB->successors())
3269+
if (Succ->isLiveIn(ARM::CPSR))
32713270
return false;
32723271
}
32733272

llvm/lib/Target/ARM/ARMISelLowering.cpp

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10956,10 +10956,9 @@ void ARMTargetLowering::EmitSjLjDispatchBlock(MachineInstr &MI,
1095610956

1095710957
static
1095810958
MachineBasicBlock *OtherSucc(MachineBasicBlock *MBB, MachineBasicBlock *Succ) {
10959-
for (MachineBasicBlock::succ_iterator I = MBB->succ_begin(),
10960-
E = MBB->succ_end(); I != E; ++I)
10961-
if (*I != Succ)
10962-
return *I;
10959+
for (MachineBasicBlock *S : MBB->successors())
10960+
if (S != Succ)
10961+
return S;
1096310962
llvm_unreachable("Expecting a BB with two successors!");
1096410963
}
1096510964

@@ -11457,13 +11456,9 @@ static bool checkAndUpdateCPSRKill(MachineBasicBlock::iterator SelectItr,
1145711456
// If we hit the end of the block, check whether CPSR is live into a
1145811457
// successor.
1145911458
if (miI == BB->end()) {
11460-
for (MachineBasicBlock::succ_iterator sItr = BB->succ_begin(),
11461-
sEnd = BB->succ_end();
11462-
sItr != sEnd; ++sItr) {
11463-
MachineBasicBlock* succ = *sItr;
11464-
if (succ->isLiveIn(ARM::CPSR))
11459+
for (MachineBasicBlock *Succ : BB->successors())
11460+
if (Succ->isLiveIn(ARM::CPSR))
1146511461
return false;
11466-
}
1146711462
}
1146811463

1146911464
// We found a def, or hit the end of the basic block and CPSR wasn't live

llvm/lib/Target/X86/X86AvoidStoreForwardingBlocks.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -360,10 +360,7 @@ findPotentialBlockers(MachineInstr *LoadInst) {
360360
if (BlockCount < InspectionLimit) {
361361
MachineBasicBlock *MBB = LoadInst->getParent();
362362
int LimitLeft = InspectionLimit - BlockCount;
363-
for (MachineBasicBlock::pred_iterator PB = MBB->pred_begin(),
364-
PE = MBB->pred_end();
365-
PB != PE; ++PB) {
366-
MachineBasicBlock *PMBB = *PB;
363+
for (MachineBasicBlock *PMBB : MBB->predecessors()) {
367364
int PredCount = 0;
368365
for (MachineInstr &PBInst : llvm::reverse(*PMBB)) {
369366
if (PBInst.isMetaInstruction())

llvm/lib/Target/X86/X86CmovConversion.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -582,10 +582,9 @@ static bool checkEFLAGSLive(MachineInstr *MI) {
582582
}
583583

584584
// We hit the end of the block, check whether EFLAGS is live into a successor.
585-
for (auto I = BB->succ_begin(), E = BB->succ_end(); I != E; ++I) {
586-
if ((*I)->isLiveIn(X86::EFLAGS))
585+
for (MachineBasicBlock *Succ : BB->successors())
586+
if (Succ->isLiveIn(X86::EFLAGS))
587587
return true;
588-
}
589588

590589
return false;
591590
}

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33095,13 +33095,9 @@ static bool isEFLAGSLiveAfter(MachineBasicBlock::iterator Itr,
3309533095

3309633096
// If we hit the end of the block, check whether EFLAGS is live into a
3309733097
// successor.
33098-
for (MachineBasicBlock::succ_iterator sItr = BB->succ_begin(),
33099-
sEnd = BB->succ_end();
33100-
sItr != sEnd; ++sItr) {
33101-
MachineBasicBlock* succ = *sItr;
33102-
if (succ->isLiveIn(X86::EFLAGS))
33098+
for (MachineBasicBlock *Succ : BB->successors())
33099+
if (Succ->isLiveIn(X86::EFLAGS))
3310333100
return true;
33104-
}
3310533101

3310633102
return false;
3310733103
}

llvm/lib/Target/X86/X86InstrInfo.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3047,13 +3047,13 @@ static MachineBasicBlock *getFallThroughMBB(MachineBasicBlock *MBB,
30473047
// and fallthrough MBB. If we find more than one, we cannot identify the
30483048
// fallthrough MBB and should return nullptr.
30493049
MachineBasicBlock *FallthroughBB = nullptr;
3050-
for (auto SI = MBB->succ_begin(), SE = MBB->succ_end(); SI != SE; ++SI) {
3051-
if ((*SI)->isEHPad() || (*SI == TBB && FallthroughBB))
3050+
for (MachineBasicBlock *Succ : MBB->successors()) {
3051+
if (Succ->isEHPad() || (Succ == TBB && FallthroughBB))
30523052
continue;
30533053
// Return a nullptr if we found more than one fallthrough successor.
30543054
if (FallthroughBB && FallthroughBB != TBB)
30553055
return nullptr;
3056-
FallthroughBB = *SI;
3056+
FallthroughBB = Succ;
30573057
}
30583058
return FallthroughBB;
30593059
}

llvm/lib/Target/X86/X86PadShortFunction.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,9 @@ void PadShortFunc::findReturns(MachineBasicBlock *MBB, unsigned int Cycles) {
174174
}
175175

176176
// Follow branches in BB and look for returns
177-
for (MachineBasicBlock::succ_iterator I = MBB->succ_begin();
178-
I != MBB->succ_end(); ++I) {
179-
if (*I == MBB)
180-
continue;
181-
findReturns(*I, Cycles);
182-
}
177+
for (MachineBasicBlock *Succ : MBB->successors())
178+
if (Succ != MBB)
179+
findReturns(Succ, Cycles);
183180
}
184181

185182
/// cyclesUntilReturn - return true if the MBB has a return instruction,

llvm/lib/Target/X86/X86VZeroUpper.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,10 +271,8 @@ void VZeroUpperInserter::processBasicBlock(MachineBasicBlock &MBB) {
271271
<< getBlockExitStateName(CurState) << '\n');
272272

273273
if (CurState == EXITS_DIRTY)
274-
for (MachineBasicBlock::succ_iterator SI = MBB.succ_begin(),
275-
SE = MBB.succ_end();
276-
SI != SE; ++SI)
277-
addDirtySuccessor(**SI);
274+
for (MachineBasicBlock *Succ : MBB.successors())
275+
addDirtySuccessor(*Succ);
278276

279277
BlockStates[MBB.getNumber()].ExitState = CurState;
280278
}

0 commit comments

Comments
 (0)