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:
parent
48654a06bf
commit
e5eb765288
@ -410,9 +410,8 @@ bool SSAIfConv::findInsertionPoint() {
|
|||||||
if (!LiveRegUnits.empty()) {
|
if (!LiveRegUnits.empty()) {
|
||||||
LLVM_DEBUG({
|
LLVM_DEBUG({
|
||||||
dbgs() << "Would clobber";
|
dbgs() << "Would clobber";
|
||||||
for (SparseSet<unsigned>::const_iterator
|
for (unsigned LRU : LiveRegUnits)
|
||||||
i = LiveRegUnits.begin(), e = LiveRegUnits.end(); i != e; ++i)
|
dbgs() << ' ' << printRegUnit(LRU, TRI);
|
||||||
dbgs() << ' ' << printRegUnit(*i, TRI);
|
|
||||||
dbgs() << " live before " << *I;
|
dbgs() << " live before " << *I;
|
||||||
});
|
});
|
||||||
continue;
|
continue;
|
||||||
|
@ -55,9 +55,8 @@ bool latency_sort::operator()(const SUnit *LHS, const SUnit *RHS) const {
|
|||||||
/// of SU, return it, otherwise return null.
|
/// of SU, return it, otherwise return null.
|
||||||
SUnit *LatencyPriorityQueue::getSingleUnscheduledPred(SUnit *SU) {
|
SUnit *LatencyPriorityQueue::getSingleUnscheduledPred(SUnit *SU) {
|
||||||
SUnit *OnlyAvailablePred = nullptr;
|
SUnit *OnlyAvailablePred = nullptr;
|
||||||
for (SUnit::const_pred_iterator I = SU->Preds.begin(), E = SU->Preds.end();
|
for (const SDep &P : SU->Preds) {
|
||||||
I != E; ++I) {
|
SUnit &Pred = *P.getSUnit();
|
||||||
SUnit &Pred = *I->getSUnit();
|
|
||||||
if (!Pred.isScheduled) {
|
if (!Pred.isScheduled) {
|
||||||
// We found an available, but not scheduled, predecessor. If it's the
|
// We found an available, but not scheduled, predecessor. If it's the
|
||||||
// only one we have found, keep track of it... otherwise give up.
|
// only one we have found, keep track of it... otherwise give up.
|
||||||
@ -90,10 +89,8 @@ void LatencyPriorityQueue::push(SUnit *SU) {
|
|||||||
// single predecessor has a higher priority, since scheduling it will make
|
// single predecessor has a higher priority, since scheduling it will make
|
||||||
// the node available.
|
// the node available.
|
||||||
void LatencyPriorityQueue::scheduledNode(SUnit *SU) {
|
void LatencyPriorityQueue::scheduledNode(SUnit *SU) {
|
||||||
for (SUnit::const_succ_iterator I = SU->Succs.begin(), E = SU->Succs.end();
|
for (const SDep &Succ : SU->Succs)
|
||||||
I != E; ++I) {
|
AdjustPriorityOfUnscheduledPreds(Succ.getSUnit());
|
||||||
AdjustPriorityOfUnscheduledPreds(I->getSUnit());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// AdjustPriorityOfUnscheduledPreds - One of the predecessors of SU was just
|
/// AdjustPriorityOfUnscheduledPreds - One of the predecessors of SU was just
|
||||||
|
@ -3199,10 +3199,10 @@ void InstrRefBasedLDV::initialSetup(MachineFunction &MF) {
|
|||||||
// Compute mappings of block <=> RPO order.
|
// Compute mappings of block <=> RPO order.
|
||||||
ReversePostOrderTraversal<MachineFunction *> RPOT(&MF);
|
ReversePostOrderTraversal<MachineFunction *> RPOT(&MF);
|
||||||
unsigned int RPONumber = 0;
|
unsigned int RPONumber = 0;
|
||||||
for (auto RI = RPOT.begin(), RE = RPOT.end(); RI != RE; ++RI) {
|
for (MachineBasicBlock *MBB : RPOT) {
|
||||||
OrderToBB[RPONumber] = *RI;
|
OrderToBB[RPONumber] = MBB;
|
||||||
BBToOrder[*RI] = RPONumber;
|
BBToOrder[MBB] = RPONumber;
|
||||||
BBNumToRPO[(*RI)->getNumber()] = RPONumber;
|
BBNumToRPO[MBB->getNumber()] = RPONumber;
|
||||||
++RPONumber;
|
++RPONumber;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1895,9 +1895,9 @@ bool VarLocBasedLDV::ExtendRanges(MachineFunction &MF, TargetPassConfig *TPC) {
|
|||||||
|
|
||||||
ReversePostOrderTraversal<MachineFunction *> RPOT(&MF);
|
ReversePostOrderTraversal<MachineFunction *> RPOT(&MF);
|
||||||
unsigned int RPONumber = 0;
|
unsigned int RPONumber = 0;
|
||||||
for (auto RI = RPOT.begin(), RE = RPOT.end(); RI != RE; ++RI) {
|
for (MachineBasicBlock *MBB : RPOT) {
|
||||||
OrderToBB[RPONumber] = *RI;
|
OrderToBB[RPONumber] = MBB;
|
||||||
BBToOrder[*RI] = RPONumber;
|
BBToOrder[MBB] = RPONumber;
|
||||||
Worklist.push(RPONumber);
|
Worklist.push(RPONumber);
|
||||||
++RPONumber;
|
++RPONumber;
|
||||||
}
|
}
|
||||||
|
@ -732,10 +732,8 @@ bool LDVImpl::handleDebugLabel(MachineInstr &MI, SlotIndex Idx) {
|
|||||||
|
|
||||||
bool LDVImpl::collectDebugValues(MachineFunction &mf) {
|
bool LDVImpl::collectDebugValues(MachineFunction &mf) {
|
||||||
bool Changed = false;
|
bool Changed = false;
|
||||||
for (MachineFunction::iterator MFI = mf.begin(), MFE = mf.end(); MFI != MFE;
|
for (MachineBasicBlock &MBB : mf) {
|
||||||
++MFI) {
|
for (MachineBasicBlock::iterator MBBI = MBB.begin(), MBBE = MBB.end();
|
||||||
MachineBasicBlock *MBB = &*MFI;
|
|
||||||
for (MachineBasicBlock::iterator MBBI = MBB->begin(), MBBE = MBB->end();
|
|
||||||
MBBI != MBBE;) {
|
MBBI != MBBE;) {
|
||||||
// Use the first debug instruction in the sequence to get a SlotIndex
|
// Use the first debug instruction in the sequence to get a SlotIndex
|
||||||
// for following consecutive debug instructions.
|
// for following consecutive debug instructions.
|
||||||
@ -746,8 +744,8 @@ bool LDVImpl::collectDebugValues(MachineFunction &mf) {
|
|||||||
// Debug instructions has no slot index. Use the previous
|
// Debug instructions has no slot index. Use the previous
|
||||||
// non-debug instruction's SlotIndex as its SlotIndex.
|
// non-debug instruction's SlotIndex as its SlotIndex.
|
||||||
SlotIndex Idx =
|
SlotIndex Idx =
|
||||||
MBBI == MBB->begin()
|
MBBI == MBB.begin()
|
||||||
? LIS->getMBBStartIdx(MBB)
|
? LIS->getMBBStartIdx(&MBB)
|
||||||
: LIS->getInstructionIndex(*std::prev(MBBI)).getRegSlot();
|
: LIS->getInstructionIndex(*std::prev(MBBI)).getRegSlot();
|
||||||
// Handle consecutive debug instructions with the same slot index.
|
// Handle consecutive debug instructions with the same slot index.
|
||||||
do {
|
do {
|
||||||
@ -756,7 +754,7 @@ bool LDVImpl::collectDebugValues(MachineFunction &mf) {
|
|||||||
if ((MBBI->isDebugValue() && handleDebugValue(*MBBI, Idx)) ||
|
if ((MBBI->isDebugValue() && handleDebugValue(*MBBI, Idx)) ||
|
||||||
(MBBI->isDebugRef() && handleDebugInstrRef(*MBBI, Idx)) ||
|
(MBBI->isDebugRef() && handleDebugInstrRef(*MBBI, Idx)) ||
|
||||||
(MBBI->isDebugLabel() && handleDebugLabel(*MBBI, Idx))) {
|
(MBBI->isDebugLabel() && handleDebugLabel(*MBBI, Idx))) {
|
||||||
MBBI = MBB->erase(MBBI);
|
MBBI = MBB.erase(MBBI);
|
||||||
Changed = true;
|
Changed = true;
|
||||||
} else
|
} else
|
||||||
++MBBI;
|
++MBBI;
|
||||||
|
@ -1336,9 +1336,8 @@ unsigned ConnectedVNInfoEqClasses::Classify(const LiveRange &LR) {
|
|||||||
const MachineBasicBlock *MBB = LIS.getMBBFromIndex(VNI->def);
|
const MachineBasicBlock *MBB = LIS.getMBBFromIndex(VNI->def);
|
||||||
assert(MBB && "Phi-def has no defining MBB");
|
assert(MBB && "Phi-def has no defining MBB");
|
||||||
// Connect to values live out of predecessors.
|
// Connect to values live out of predecessors.
|
||||||
for (MachineBasicBlock::const_pred_iterator PI = MBB->pred_begin(),
|
for (MachineBasicBlock *Pred : MBB->predecessors())
|
||||||
PE = MBB->pred_end(); PI != PE; ++PI)
|
if (const VNInfo *PVNI = LR.getVNInfoBefore(LIS.getMBBEndIdx(Pred)))
|
||||||
if (const VNInfo *PVNI = LR.getVNInfoBefore(LIS.getMBBEndIdx(*PI)))
|
|
||||||
EqClass.join(VNI->id, PVNI->id);
|
EqClass.join(VNI->id, PVNI->id);
|
||||||
} else {
|
} else {
|
||||||
// Normal value defined by an instruction. Check for two-addr redef.
|
// Normal value defined by an instruction. Check for two-addr redef.
|
||||||
|
@ -125,8 +125,8 @@ void LivePhysRegs::print(raw_ostream &OS) const {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const_iterator I = begin(), E = end(); I != E; ++I)
|
for (MCPhysReg R : *this)
|
||||||
OS << " " << printReg(*I, TRI);
|
OS << " " << printReg(R, TRI);
|
||||||
OS << "\n";
|
OS << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,9 +67,8 @@ LiveVariables::VarInfo::findKill(const MachineBasicBlock *MBB) const {
|
|||||||
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
|
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
|
||||||
LLVM_DUMP_METHOD void LiveVariables::VarInfo::dump() const {
|
LLVM_DUMP_METHOD void LiveVariables::VarInfo::dump() const {
|
||||||
dbgs() << " Alive in blocks: ";
|
dbgs() << " Alive in blocks: ";
|
||||||
for (SparseBitVector<>::iterator I = AliveBlocks.begin(),
|
for (unsigned AB : AliveBlocks)
|
||||||
E = AliveBlocks.end(); I != E; ++I)
|
dbgs() << AB << ", ";
|
||||||
dbgs() << *I << ", ";
|
|
||||||
dbgs() << "\n Killed by:";
|
dbgs() << "\n Killed by:";
|
||||||
if (Kills.empty())
|
if (Kills.empty())
|
||||||
dbgs() << " No instructions.\n";
|
dbgs() << " No instructions.\n";
|
||||||
@ -173,9 +172,8 @@ void LiveVariables::HandleVirtRegUse(Register Reg, MachineBasicBlock *MBB,
|
|||||||
VRInfo.Kills.push_back(&MI);
|
VRInfo.Kills.push_back(&MI);
|
||||||
|
|
||||||
// Update all dominating blocks to mark them as "known live".
|
// Update all dominating blocks to mark them as "known live".
|
||||||
for (MachineBasicBlock::const_pred_iterator PI = MBB->pred_begin(),
|
for (MachineBasicBlock *Pred : MBB->predecessors())
|
||||||
E = MBB->pred_end(); PI != E; ++PI)
|
MarkVirtRegAliveInBlock(VRInfo, MRI->getVRegDef(Reg)->getParent(), Pred);
|
||||||
MarkVirtRegAliveInBlock(VRInfo, MRI->getVRegDef(Reg)->getParent(), *PI);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LiveVariables::HandleVirtRegDef(Register Reg, MachineInstr &MI) {
|
void LiveVariables::HandleVirtRegDef(Register Reg, MachineInstr &MI) {
|
||||||
@ -588,19 +586,16 @@ void LiveVariables::runOnBlock(MachineBasicBlock *MBB, const unsigned NumRegs) {
|
|||||||
if (!PHIVarInfo[MBB->getNumber()].empty()) {
|
if (!PHIVarInfo[MBB->getNumber()].empty()) {
|
||||||
SmallVectorImpl<unsigned> &VarInfoVec = PHIVarInfo[MBB->getNumber()];
|
SmallVectorImpl<unsigned> &VarInfoVec = PHIVarInfo[MBB->getNumber()];
|
||||||
|
|
||||||
for (SmallVectorImpl<unsigned>::iterator I = VarInfoVec.begin(),
|
for (unsigned I : VarInfoVec)
|
||||||
E = VarInfoVec.end(); I != E; ++I)
|
|
||||||
// Mark it alive only in the block we are representing.
|
// Mark it alive only in the block we are representing.
|
||||||
MarkVirtRegAliveInBlock(getVarInfo(*I),MRI->getVRegDef(*I)->getParent(),
|
MarkVirtRegAliveInBlock(getVarInfo(I), MRI->getVRegDef(I)->getParent(),
|
||||||
MBB);
|
MBB);
|
||||||
}
|
}
|
||||||
|
|
||||||
// MachineCSE may CSE instructions which write to non-allocatable physical
|
// MachineCSE may CSE instructions which write to non-allocatable physical
|
||||||
// registers across MBBs. Remember if any reserved register is liveout.
|
// registers across MBBs. Remember if any reserved register is liveout.
|
||||||
SmallSet<unsigned, 4> LiveOuts;
|
SmallSet<unsigned, 4> LiveOuts;
|
||||||
for (MachineBasicBlock::const_succ_iterator SI = MBB->succ_begin(),
|
for (const MachineBasicBlock *SuccMBB : MBB->successors()) {
|
||||||
SE = MBB->succ_end(); SI != SE; ++SI) {
|
|
||||||
MachineBasicBlock *SuccMBB = *SI;
|
|
||||||
if (SuccMBB->isEHPad())
|
if (SuccMBB->isEHPad())
|
||||||
continue;
|
continue;
|
||||||
for (const auto &LI : SuccMBB->liveins()) {
|
for (const auto &LI : SuccMBB->liveins()) {
|
||||||
@ -665,8 +660,8 @@ bool LiveVariables::runOnMachineFunction(MachineFunction &mf) {
|
|||||||
// function. If so, it is due to a bug in the instruction selector or some
|
// function. If so, it is due to a bug in the instruction selector or some
|
||||||
// other part of the code generator if this happens.
|
// other part of the code generator if this happens.
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
for(MachineFunction::iterator i = MF->begin(), e = MF->end(); i != e; ++i)
|
for (const MachineBasicBlock &MBB : *MF)
|
||||||
assert(Visited.contains(&*i) && "unreachable basic block found");
|
assert(Visited.contains(&MBB) && "unreachable basic block found");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
PhysRegDef.clear();
|
PhysRegDef.clear();
|
||||||
@ -817,8 +812,8 @@ void LiveVariables::addNewBlock(MachineBasicBlock *BB,
|
|||||||
const unsigned NumNew = BB->getNumber();
|
const unsigned NumNew = BB->getNumber();
|
||||||
|
|
||||||
SparseBitVector<> &BV = LiveInSets[SuccBB->getNumber()];
|
SparseBitVector<> &BV = LiveInSets[SuccBB->getNumber()];
|
||||||
for (auto R = BV.begin(), E = BV.end(); R != E; R++) {
|
for (unsigned R : BV) {
|
||||||
Register VirtReg = Register::index2VirtReg(*R);
|
Register VirtReg = Register::index2VirtReg(R);
|
||||||
LiveVariables::VarInfo &VI = getVarInfo(VirtReg);
|
LiveVariables::VarInfo &VI = getVarInfo(VirtReg);
|
||||||
VI.AliveBlocks.set(NumNew);
|
VI.AliveBlocks.set(NumNew);
|
||||||
}
|
}
|
||||||
|
@ -176,9 +176,7 @@ void LocalStackSlotPass::AssignProtectedObjSet(
|
|||||||
const StackObjSet &UnassignedObjs, SmallSet<int, 16> &ProtectedObjs,
|
const StackObjSet &UnassignedObjs, SmallSet<int, 16> &ProtectedObjs,
|
||||||
MachineFrameInfo &MFI, bool StackGrowsDown, int64_t &Offset,
|
MachineFrameInfo &MFI, bool StackGrowsDown, int64_t &Offset,
|
||||||
Align &MaxAlign) {
|
Align &MaxAlign) {
|
||||||
for (StackObjSet::const_iterator I = UnassignedObjs.begin(),
|
for (int i : UnassignedObjs) {
|
||||||
E = UnassignedObjs.end(); I != E; ++I) {
|
|
||||||
int i = *I;
|
|
||||||
AdjustStackOffset(MFI, i, Offset, StackGrowsDown, MaxAlign);
|
AdjustStackOffset(MFI, i, Offset, StackGrowsDown, MaxAlign);
|
||||||
ProtectedObjs.insert(i);
|
ProtectedObjs.insert(i);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user