mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 10:42:39 +01:00
[CodeGen] Use range-based for loops (NFC)
This commit is contained in:
parent
c411b22a9b
commit
63f16fef3a
@ -434,8 +434,8 @@ void MachineRegisterInfo::clearKillFlags(Register Reg) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool MachineRegisterInfo::isLiveIn(Register Reg) const {
|
bool MachineRegisterInfo::isLiveIn(Register Reg) const {
|
||||||
for (livein_iterator I = livein_begin(), E = livein_end(); I != E; ++I)
|
for (const std::pair<MCRegister, Register> &LI : liveins())
|
||||||
if ((Register)I->first == Reg || I->second == Reg)
|
if ((Register)LI.first == Reg || LI.second == Reg)
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -443,18 +443,18 @@ bool MachineRegisterInfo::isLiveIn(Register Reg) const {
|
|||||||
/// getLiveInPhysReg - If VReg is a live-in virtual register, return the
|
/// getLiveInPhysReg - If VReg is a live-in virtual register, return the
|
||||||
/// corresponding live-in physical register.
|
/// corresponding live-in physical register.
|
||||||
MCRegister MachineRegisterInfo::getLiveInPhysReg(Register VReg) const {
|
MCRegister MachineRegisterInfo::getLiveInPhysReg(Register VReg) const {
|
||||||
for (livein_iterator I = livein_begin(), E = livein_end(); I != E; ++I)
|
for (const std::pair<MCRegister, Register> &LI : liveins())
|
||||||
if (I->second == VReg)
|
if (LI.second == VReg)
|
||||||
return I->first;
|
return LI.first;
|
||||||
return MCRegister();
|
return MCRegister();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// getLiveInVirtReg - If PReg is a live-in physical register, return the
|
/// getLiveInVirtReg - If PReg is a live-in physical register, return the
|
||||||
/// corresponding live-in physical register.
|
/// corresponding live-in physical register.
|
||||||
Register MachineRegisterInfo::getLiveInVirtReg(MCRegister PReg) const {
|
Register MachineRegisterInfo::getLiveInVirtReg(MCRegister PReg) const {
|
||||||
for (livein_iterator I = livein_begin(), E = livein_end(); I != E; ++I)
|
for (const std::pair<MCRegister, Register> &LI : liveins())
|
||||||
if (I->first == PReg)
|
if (LI.first == PReg)
|
||||||
return I->second;
|
return LI.second;
|
||||||
return Register();
|
return Register();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,9 +164,7 @@ Register MachineSSAUpdater::GetValueInMiddleOfBlock(MachineBasicBlock *BB) {
|
|||||||
Register SingularValue;
|
Register SingularValue;
|
||||||
|
|
||||||
bool isFirstPred = true;
|
bool isFirstPred = true;
|
||||||
for (MachineBasicBlock::pred_iterator PI = BB->pred_begin(),
|
for (MachineBasicBlock *PredBB : BB->predecessors()) {
|
||||||
E = BB->pred_end(); PI != E; ++PI) {
|
|
||||||
MachineBasicBlock *PredBB = *PI;
|
|
||||||
Register PredVal = GetValueAtEndOfBlockInternal(PredBB);
|
Register PredVal = GetValueAtEndOfBlockInternal(PredBB);
|
||||||
PredValues.push_back(std::make_pair(PredBB, PredVal));
|
PredValues.push_back(std::make_pair(PredBB, PredVal));
|
||||||
|
|
||||||
|
@ -550,9 +550,8 @@ void PHIElimination::LowerPHINode(MachineBasicBlock &MBB,
|
|||||||
LiveInterval &SrcLI = LIS->getInterval(SrcReg);
|
LiveInterval &SrcLI = LIS->getInterval(SrcReg);
|
||||||
|
|
||||||
bool isLiveOut = false;
|
bool isLiveOut = false;
|
||||||
for (MachineBasicBlock::succ_iterator SI = opBlock.succ_begin(),
|
for (MachineBasicBlock *Succ : opBlock.successors()) {
|
||||||
SE = opBlock.succ_end(); SI != SE; ++SI) {
|
SlotIndex startIdx = LIS->getMBBStartIdx(Succ);
|
||||||
SlotIndex startIdx = LIS->getMBBStartIdx(*SI);
|
|
||||||
VNInfo *VNI = SrcLI.getVNInfoAt(startIdx);
|
VNInfo *VNI = SrcLI.getVNInfoAt(startIdx);
|
||||||
|
|
||||||
// Definitions by other PHIs are not truly live-in for our purposes.
|
// Definitions by other PHIs are not truly live-in for our purposes.
|
||||||
|
@ -866,8 +866,8 @@ void Liveness::computeLiveIns() {
|
|||||||
// Dump the liveness map
|
// Dump the liveness map
|
||||||
for (MachineBasicBlock &B : MF) {
|
for (MachineBasicBlock &B : MF) {
|
||||||
std::vector<RegisterRef> LV;
|
std::vector<RegisterRef> LV;
|
||||||
for (auto I = B.livein_begin(), E = B.livein_end(); I != E; ++I)
|
for (const MachineBasicBlock::RegisterMaskPair &LI : B.liveins())
|
||||||
LV.push_back(RegisterRef(I->PhysReg, I->LaneMask));
|
LV.push_back(RegisterRef(LI.PhysReg, LI.LaneMask));
|
||||||
llvm::sort(LV);
|
llvm::sort(LV);
|
||||||
dbgs() << printMBBReference(B) << "\t rec = {";
|
dbgs() << printMBBReference(B) << "\t rec = {";
|
||||||
for (auto I : LV)
|
for (auto I : LV)
|
||||||
@ -893,16 +893,14 @@ void Liveness::resetLiveIns() {
|
|||||||
for (auto &B : DFG.getMF()) {
|
for (auto &B : DFG.getMF()) {
|
||||||
// Remove all live-ins.
|
// Remove all live-ins.
|
||||||
std::vector<unsigned> T;
|
std::vector<unsigned> T;
|
||||||
for (auto I = B.livein_begin(), E = B.livein_end(); I != E; ++I)
|
for (const MachineBasicBlock::RegisterMaskPair &LI : B.liveins())
|
||||||
T.push_back(I->PhysReg);
|
T.push_back(LI.PhysReg);
|
||||||
for (auto I : T)
|
for (auto I : T)
|
||||||
B.removeLiveIn(I);
|
B.removeLiveIn(I);
|
||||||
// Add the newly computed live-ins.
|
// Add the newly computed live-ins.
|
||||||
const RegisterAggr &LiveIns = LiveMap[&B];
|
const RegisterAggr &LiveIns = LiveMap[&B];
|
||||||
for (auto I = LiveIns.rr_begin(), E = LiveIns.rr_end(); I != E; ++I) {
|
for (const RegisterRef &R : make_range(LiveIns.rr_begin(), LiveIns.rr_end()))
|
||||||
RegisterRef R = *I;
|
|
||||||
B.addLiveIn({MCPhysReg(R.Reg), R.Mask});
|
B.addLiveIn({MCPhysReg(R.Reg), R.Mask});
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -678,9 +678,8 @@ unsigned StackColoring::collectMarkers(unsigned NumSlot) {
|
|||||||
// to this bb).
|
// to this bb).
|
||||||
BitVector BetweenStartEnd;
|
BitVector BetweenStartEnd;
|
||||||
BetweenStartEnd.resize(NumSlot);
|
BetweenStartEnd.resize(NumSlot);
|
||||||
for (MachineBasicBlock::const_pred_iterator PI = MBB->pred_begin(),
|
for (const MachineBasicBlock *Pred : MBB->predecessors()) {
|
||||||
PE = MBB->pred_end(); PI != PE; ++PI) {
|
BlockBitVecMap::const_iterator I = SeenStartMap.find(Pred);
|
||||||
BlockBitVecMap::const_iterator I = SeenStartMap.find(*PI);
|
|
||||||
if (I != SeenStartMap.end()) {
|
if (I != SeenStartMap.end()) {
|
||||||
BetweenStartEnd |= I->second;
|
BetweenStartEnd |= I->second;
|
||||||
}
|
}
|
||||||
@ -819,9 +818,8 @@ void StackColoring::calculateLocalLiveness() {
|
|||||||
|
|
||||||
// Compute LiveIn by unioning together the LiveOut sets of all preds.
|
// Compute LiveIn by unioning together the LiveOut sets of all preds.
|
||||||
BitVector LocalLiveIn;
|
BitVector LocalLiveIn;
|
||||||
for (MachineBasicBlock::const_pred_iterator PI = BB->pred_begin(),
|
for (MachineBasicBlock *Pred : BB->predecessors()) {
|
||||||
PE = BB->pred_end(); PI != PE; ++PI) {
|
LivenessMap::const_iterator I = BlockLiveness.find(Pred);
|
||||||
LivenessMap::const_iterator I = BlockLiveness.find(*PI);
|
|
||||||
// PR37130: transformations prior to stack coloring can
|
// PR37130: transformations prior to stack coloring can
|
||||||
// sometimes leave behind statically unreachable blocks; these
|
// sometimes leave behind statically unreachable blocks; these
|
||||||
// can be safely skipped here.
|
// can be safely skipped here.
|
||||||
|
@ -1035,10 +1035,9 @@ void TailDuplicator::removeDeadBlock(
|
|||||||
|
|
||||||
MachineFunction *MF = MBB->getParent();
|
MachineFunction *MF = MBB->getParent();
|
||||||
// Update the call site info.
|
// Update the call site info.
|
||||||
std::for_each(MBB->begin(), MBB->end(), [MF](const MachineInstr &MI) {
|
for (const MachineInstr &MI : *MBB)
|
||||||
if (MI.shouldUpdateCallSiteInfo())
|
if (MI.shouldUpdateCallSiteInfo())
|
||||||
MF->eraseCallSiteInfo(&MI);
|
MF->eraseCallSiteInfo(&MI);
|
||||||
});
|
|
||||||
|
|
||||||
if (RemovalCallback)
|
if (RemovalCallback)
|
||||||
(*RemovalCallback)(MBB);
|
(*RemovalCallback)(MBB);
|
||||||
|
@ -714,16 +714,14 @@ void WinEHPrepare::demotePHIsOnFunclets(Function &F,
|
|||||||
bool DemoteCatchSwitchPHIOnly) {
|
bool DemoteCatchSwitchPHIOnly) {
|
||||||
// Strip PHI nodes off of EH pads.
|
// Strip PHI nodes off of EH pads.
|
||||||
SmallVector<PHINode *, 16> PHINodes;
|
SmallVector<PHINode *, 16> PHINodes;
|
||||||
for (Function::iterator FI = F.begin(), FE = F.end(); FI != FE;) {
|
for (BasicBlock &BB : make_early_inc_range(F)) {
|
||||||
BasicBlock *BB = &*FI++;
|
if (!BB.isEHPad())
|
||||||
if (!BB->isEHPad())
|
|
||||||
continue;
|
continue;
|
||||||
if (DemoteCatchSwitchPHIOnly && !isa<CatchSwitchInst>(BB->getFirstNonPHI()))
|
if (DemoteCatchSwitchPHIOnly && !isa<CatchSwitchInst>(BB.getFirstNonPHI()))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for (BasicBlock::iterator BI = BB->begin(), BE = BB->end(); BI != BE;) {
|
for (Instruction &I : make_early_inc_range(BB)) {
|
||||||
Instruction *I = &*BI++;
|
auto *PN = dyn_cast<PHINode>(&I);
|
||||||
auto *PN = dyn_cast<PHINode>(I);
|
|
||||||
// Stop at the first non-PHI.
|
// Stop at the first non-PHI.
|
||||||
if (!PN)
|
if (!PN)
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user