1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 02:33:06 +01:00

[CodeGen] Use range-based for loops (NFC)

This commit is contained in:
Kazu Hirata 2021-02-19 22:44:14 -08:00
parent c411b22a9b
commit 63f16fef3a
7 changed files with 26 additions and 36 deletions

View File

@ -434,8 +434,8 @@ void MachineRegisterInfo::clearKillFlags(Register Reg) const {
}
bool MachineRegisterInfo::isLiveIn(Register Reg) const {
for (livein_iterator I = livein_begin(), E = livein_end(); I != E; ++I)
if ((Register)I->first == Reg || I->second == Reg)
for (const std::pair<MCRegister, Register> &LI : liveins())
if ((Register)LI.first == Reg || LI.second == Reg)
return true;
return false;
}
@ -443,18 +443,18 @@ bool MachineRegisterInfo::isLiveIn(Register Reg) const {
/// getLiveInPhysReg - If VReg is a live-in virtual register, return the
/// corresponding live-in physical register.
MCRegister MachineRegisterInfo::getLiveInPhysReg(Register VReg) const {
for (livein_iterator I = livein_begin(), E = livein_end(); I != E; ++I)
if (I->second == VReg)
return I->first;
for (const std::pair<MCRegister, Register> &LI : liveins())
if (LI.second == VReg)
return LI.first;
return MCRegister();
}
/// getLiveInVirtReg - If PReg is a live-in physical register, return the
/// corresponding live-in physical register.
Register MachineRegisterInfo::getLiveInVirtReg(MCRegister PReg) const {
for (livein_iterator I = livein_begin(), E = livein_end(); I != E; ++I)
if (I->first == PReg)
return I->second;
for (const std::pair<MCRegister, Register> &LI : liveins())
if (LI.first == PReg)
return LI.second;
return Register();
}

View File

@ -164,9 +164,7 @@ Register MachineSSAUpdater::GetValueInMiddleOfBlock(MachineBasicBlock *BB) {
Register SingularValue;
bool isFirstPred = true;
for (MachineBasicBlock::pred_iterator PI = BB->pred_begin(),
E = BB->pred_end(); PI != E; ++PI) {
MachineBasicBlock *PredBB = *PI;
for (MachineBasicBlock *PredBB : BB->predecessors()) {
Register PredVal = GetValueAtEndOfBlockInternal(PredBB);
PredValues.push_back(std::make_pair(PredBB, PredVal));

View File

@ -550,9 +550,8 @@ void PHIElimination::LowerPHINode(MachineBasicBlock &MBB,
LiveInterval &SrcLI = LIS->getInterval(SrcReg);
bool isLiveOut = false;
for (MachineBasicBlock::succ_iterator SI = opBlock.succ_begin(),
SE = opBlock.succ_end(); SI != SE; ++SI) {
SlotIndex startIdx = LIS->getMBBStartIdx(*SI);
for (MachineBasicBlock *Succ : opBlock.successors()) {
SlotIndex startIdx = LIS->getMBBStartIdx(Succ);
VNInfo *VNI = SrcLI.getVNInfoAt(startIdx);
// Definitions by other PHIs are not truly live-in for our purposes.

View File

@ -866,8 +866,8 @@ void Liveness::computeLiveIns() {
// Dump the liveness map
for (MachineBasicBlock &B : MF) {
std::vector<RegisterRef> LV;
for (auto I = B.livein_begin(), E = B.livein_end(); I != E; ++I)
LV.push_back(RegisterRef(I->PhysReg, I->LaneMask));
for (const MachineBasicBlock::RegisterMaskPair &LI : B.liveins())
LV.push_back(RegisterRef(LI.PhysReg, LI.LaneMask));
llvm::sort(LV);
dbgs() << printMBBReference(B) << "\t rec = {";
for (auto I : LV)
@ -893,17 +893,15 @@ void Liveness::resetLiveIns() {
for (auto &B : DFG.getMF()) {
// Remove all live-ins.
std::vector<unsigned> T;
for (auto I = B.livein_begin(), E = B.livein_end(); I != E; ++I)
T.push_back(I->PhysReg);
for (const MachineBasicBlock::RegisterMaskPair &LI : B.liveins())
T.push_back(LI.PhysReg);
for (auto I : T)
B.removeLiveIn(I);
// Add the newly computed live-ins.
const RegisterAggr &LiveIns = LiveMap[&B];
for (auto I = LiveIns.rr_begin(), E = LiveIns.rr_end(); I != E; ++I) {
RegisterRef R = *I;
for (const RegisterRef &R : make_range(LiveIns.rr_begin(), LiveIns.rr_end()))
B.addLiveIn({MCPhysReg(R.Reg), R.Mask});
}
}
}
void Liveness::resetKills() {

View File

@ -678,9 +678,8 @@ unsigned StackColoring::collectMarkers(unsigned NumSlot) {
// to this bb).
BitVector BetweenStartEnd;
BetweenStartEnd.resize(NumSlot);
for (MachineBasicBlock::const_pred_iterator PI = MBB->pred_begin(),
PE = MBB->pred_end(); PI != PE; ++PI) {
BlockBitVecMap::const_iterator I = SeenStartMap.find(*PI);
for (const MachineBasicBlock *Pred : MBB->predecessors()) {
BlockBitVecMap::const_iterator I = SeenStartMap.find(Pred);
if (I != SeenStartMap.end()) {
BetweenStartEnd |= I->second;
}
@ -819,9 +818,8 @@ void StackColoring::calculateLocalLiveness() {
// Compute LiveIn by unioning together the LiveOut sets of all preds.
BitVector LocalLiveIn;
for (MachineBasicBlock::const_pred_iterator PI = BB->pred_begin(),
PE = BB->pred_end(); PI != PE; ++PI) {
LivenessMap::const_iterator I = BlockLiveness.find(*PI);
for (MachineBasicBlock *Pred : BB->predecessors()) {
LivenessMap::const_iterator I = BlockLiveness.find(Pred);
// PR37130: transformations prior to stack coloring can
// sometimes leave behind statically unreachable blocks; these
// can be safely skipped here.

View File

@ -1035,10 +1035,9 @@ void TailDuplicator::removeDeadBlock(
MachineFunction *MF = MBB->getParent();
// Update the call site info.
std::for_each(MBB->begin(), MBB->end(), [MF](const MachineInstr &MI) {
for (const MachineInstr &MI : *MBB)
if (MI.shouldUpdateCallSiteInfo())
MF->eraseCallSiteInfo(&MI);
});
if (RemovalCallback)
(*RemovalCallback)(MBB);

View File

@ -714,16 +714,14 @@ void WinEHPrepare::demotePHIsOnFunclets(Function &F,
bool DemoteCatchSwitchPHIOnly) {
// Strip PHI nodes off of EH pads.
SmallVector<PHINode *, 16> PHINodes;
for (Function::iterator FI = F.begin(), FE = F.end(); FI != FE;) {
BasicBlock *BB = &*FI++;
if (!BB->isEHPad())
for (BasicBlock &BB : make_early_inc_range(F)) {
if (!BB.isEHPad())
continue;
if (DemoteCatchSwitchPHIOnly && !isa<CatchSwitchInst>(BB->getFirstNonPHI()))
if (DemoteCatchSwitchPHIOnly && !isa<CatchSwitchInst>(BB.getFirstNonPHI()))
continue;
for (BasicBlock::iterator BI = BB->begin(), BE = BB->end(); BI != BE;) {
Instruction *I = &*BI++;
auto *PN = dyn_cast<PHINode>(I);
for (Instruction &I : make_early_inc_range(BB)) {
auto *PN = dyn_cast<PHINode>(&I);
// Stop at the first non-PHI.
if (!PN)
break;