mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-25 04:02:41 +01:00
[CodeGen] Use range-based for loops (NFC)
This commit is contained in:
parent
3912ea99c3
commit
249aa54f98
@ -703,9 +703,8 @@ void RegAllocPBQP::spillVReg(Register VReg,
|
||||
|
||||
// Copy any newly inserted live intervals into the list of regs to
|
||||
// allocate.
|
||||
for (LiveRangeEdit::iterator I = LRE.begin(), E = LRE.end();
|
||||
I != E; ++I) {
|
||||
const LiveInterval &LI = LIS.getInterval(*I);
|
||||
for (const Register &R : LRE) {
|
||||
const LiveInterval &LI = LIS.getInterval(R);
|
||||
assert(!LI.empty() && "Empty spill range.");
|
||||
LLVM_DEBUG(dbgs() << printReg(LI.reg(), &TRI) << " ");
|
||||
VRegsToAlloc.insert(LI.reg());
|
||||
@ -759,10 +758,8 @@ void RegAllocPBQP::finalizeAlloc(MachineFunction &MF,
|
||||
MachineRegisterInfo &MRI = MF.getRegInfo();
|
||||
|
||||
// First allocate registers for the empty intervals.
|
||||
for (RegSet::const_iterator
|
||||
I = EmptyIntervalVRegs.begin(), E = EmptyIntervalVRegs.end();
|
||||
I != E; ++I) {
|
||||
LiveInterval &LI = LIS.getInterval(*I);
|
||||
for (const Register &R : EmptyIntervalVRegs) {
|
||||
LiveInterval &LI = LIS.getInterval(R);
|
||||
|
||||
Register PReg = MRI.getSimpleHint(LI.reg());
|
||||
|
||||
|
@ -3877,21 +3877,20 @@ RegisterCoalescer::copyCoalesceInMBB(MachineBasicBlock *MBB) {
|
||||
// are not inherently easier to resolve, but slightly preferable until we
|
||||
// have local live range splitting. In particular this is required by
|
||||
// cmp+jmp macro fusion.
|
||||
for (MachineBasicBlock::iterator MII = MBB->begin(), E = MBB->end();
|
||||
MII != E; ++MII) {
|
||||
if (!MII->isCopyLike())
|
||||
for (MachineInstr &MI : *MBB) {
|
||||
if (!MI.isCopyLike())
|
||||
continue;
|
||||
bool ApplyTerminalRule = applyTerminalRule(*MII);
|
||||
if (isLocalCopy(&(*MII), LIS)) {
|
||||
bool ApplyTerminalRule = applyTerminalRule(MI);
|
||||
if (isLocalCopy(&MI, LIS)) {
|
||||
if (ApplyTerminalRule)
|
||||
LocalTerminals.push_back(&(*MII));
|
||||
LocalTerminals.push_back(&MI);
|
||||
else
|
||||
LocalWorkList.push_back(&(*MII));
|
||||
LocalWorkList.push_back(&MI);
|
||||
} else {
|
||||
if (ApplyTerminalRule)
|
||||
GlobalTerminals.push_back(&(*MII));
|
||||
GlobalTerminals.push_back(&MI);
|
||||
else
|
||||
WorkList.push_back(&(*MII));
|
||||
WorkList.push_back(&MI);
|
||||
}
|
||||
}
|
||||
// Append the copies evicted by the terminal rule at the end of the list.
|
||||
@ -3935,10 +3934,9 @@ void RegisterCoalescer::joinAllIntervals() {
|
||||
|
||||
std::vector<MBBPriorityInfo> MBBs;
|
||||
MBBs.reserve(MF->size());
|
||||
for (MachineFunction::iterator I = MF->begin(), E = MF->end(); I != E; ++I) {
|
||||
MachineBasicBlock *MBB = &*I;
|
||||
MBBs.push_back(MBBPriorityInfo(MBB, Loops->getLoopDepth(MBB),
|
||||
JoinSplitEdges && isSplitEdge(MBB)));
|
||||
for (MachineBasicBlock &MBB : *MF) {
|
||||
MBBs.push_back(MBBPriorityInfo(&MBB, Loops->getLoopDepth(&MBB),
|
||||
JoinSplitEdges && isSplitEdge(&MBB)));
|
||||
}
|
||||
array_pod_sort(MBBs.begin(), MBBs.end(), compareMBBPriority);
|
||||
|
||||
|
@ -167,13 +167,12 @@ void RegScavenger::forward() {
|
||||
|
||||
MachineInstr &MI = *MBBI;
|
||||
|
||||
for (SmallVectorImpl<ScavengedInfo>::iterator I = Scavenged.begin(),
|
||||
IE = Scavenged.end(); I != IE; ++I) {
|
||||
if (I->Restore != &MI)
|
||||
for (ScavengedInfo &I : Scavenged) {
|
||||
if (I.Restore != &MI)
|
||||
continue;
|
||||
|
||||
I->Reg = 0;
|
||||
I->Restore = nullptr;
|
||||
I.Reg = 0;
|
||||
I.Restore = nullptr;
|
||||
}
|
||||
|
||||
if (MI.isDebugInstr())
|
||||
|
@ -238,8 +238,8 @@ void ShadowStackGCLowering::CollectRoots(Function &F) {
|
||||
|
||||
SmallVector<std::pair<CallInst *, AllocaInst *>, 16> MetaRoots;
|
||||
|
||||
for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB)
|
||||
for (BasicBlock::iterator II = BB->begin(), E = BB->end(); II != E;)
|
||||
for (BasicBlock &BB : F)
|
||||
for (BasicBlock::iterator II = BB.begin(), E = BB.end(); II != E;)
|
||||
if (IntrinsicInst *CI = dyn_cast<IntrinsicInst>(II++))
|
||||
if (Function *F = CI->getCalledFunction())
|
||||
if (F->getIntrinsicID() == Intrinsic::gcroot) {
|
||||
|
@ -248,12 +248,11 @@ void SlotIndexes::repairIndexesInRange(MachineBasicBlock *MBB,
|
||||
|
||||
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
|
||||
LLVM_DUMP_METHOD void SlotIndexes::dump() const {
|
||||
for (IndexList::const_iterator itr = indexList.begin();
|
||||
itr != indexList.end(); ++itr) {
|
||||
dbgs() << itr->getIndex() << " ";
|
||||
for (const IndexListEntry &ILE : indexList) {
|
||||
dbgs() << ILE.getIndex() << " ";
|
||||
|
||||
if (itr->getInstr()) {
|
||||
dbgs() << *itr->getInstr();
|
||||
if (ILE.getInstr()) {
|
||||
dbgs() << *ILE.getInstr();
|
||||
} else {
|
||||
dbgs() << "\n";
|
||||
}
|
||||
@ -280,4 +279,3 @@ LLVM_DUMP_METHOD void SlotIndex::dump() const {
|
||||
dbgs() << "\n";
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -121,9 +121,9 @@ struct SpillPlacement::Node {
|
||||
SumLinkWeights += w;
|
||||
|
||||
// There can be multiple links to the same bundle, add them up.
|
||||
for (LinkVector::iterator I = Links.begin(), E = Links.end(); I != E; ++I)
|
||||
if (I->second == b) {
|
||||
I->first += w;
|
||||
for (std::pair<BlockFrequency, unsigned> &L : Links)
|
||||
if (L.second == b) {
|
||||
L.first += w;
|
||||
return;
|
||||
}
|
||||
// This must be the first link to b.
|
||||
@ -153,11 +153,11 @@ struct SpillPlacement::Node {
|
||||
// Compute the weighted sum of inputs.
|
||||
BlockFrequency SumN = BiasN;
|
||||
BlockFrequency SumP = BiasP;
|
||||
for (LinkVector::iterator I = Links.begin(), E = Links.end(); I != E; ++I) {
|
||||
if (nodes[I->second].Value == -1)
|
||||
SumN += I->first;
|
||||
else if (nodes[I->second].Value == 1)
|
||||
SumP += I->first;
|
||||
for (std::pair<BlockFrequency, unsigned> &L : Links) {
|
||||
if (nodes[L.second].Value == -1)
|
||||
SumN += L.first;
|
||||
else if (nodes[L.second].Value == 1)
|
||||
SumP += L.first;
|
||||
}
|
||||
|
||||
// Each weighted sum is going to be less than the total frequency of the
|
||||
@ -258,35 +258,33 @@ void SpillPlacement::setThreshold(const BlockFrequency &Entry) {
|
||||
/// addConstraints - Compute node biases and weights from a set of constraints.
|
||||
/// Set a bit in NodeMask for each active node.
|
||||
void SpillPlacement::addConstraints(ArrayRef<BlockConstraint> LiveBlocks) {
|
||||
for (ArrayRef<BlockConstraint>::iterator I = LiveBlocks.begin(),
|
||||
E = LiveBlocks.end(); I != E; ++I) {
|
||||
BlockFrequency Freq = BlockFrequencies[I->Number];
|
||||
for (const BlockConstraint &LB : LiveBlocks) {
|
||||
BlockFrequency Freq = BlockFrequencies[LB.Number];
|
||||
|
||||
// Live-in to block?
|
||||
if (I->Entry != DontCare) {
|
||||
unsigned ib = bundles->getBundle(I->Number, false);
|
||||
if (LB.Entry != DontCare) {
|
||||
unsigned ib = bundles->getBundle(LB.Number, false);
|
||||
activate(ib);
|
||||
nodes[ib].addBias(Freq, I->Entry);
|
||||
nodes[ib].addBias(Freq, LB.Entry);
|
||||
}
|
||||
|
||||
// Live-out from block?
|
||||
if (I->Exit != DontCare) {
|
||||
unsigned ob = bundles->getBundle(I->Number, true);
|
||||
if (LB.Exit != DontCare) {
|
||||
unsigned ob = bundles->getBundle(LB.Number, true);
|
||||
activate(ob);
|
||||
nodes[ob].addBias(Freq, I->Exit);
|
||||
nodes[ob].addBias(Freq, LB.Exit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// addPrefSpill - Same as addConstraints(PrefSpill)
|
||||
void SpillPlacement::addPrefSpill(ArrayRef<unsigned> Blocks, bool Strong) {
|
||||
for (ArrayRef<unsigned>::iterator I = Blocks.begin(), E = Blocks.end();
|
||||
I != E; ++I) {
|
||||
BlockFrequency Freq = BlockFrequencies[*I];
|
||||
for (unsigned B : Blocks) {
|
||||
BlockFrequency Freq = BlockFrequencies[B];
|
||||
if (Strong)
|
||||
Freq += Freq;
|
||||
unsigned ib = bundles->getBundle(*I, false);
|
||||
unsigned ob = bundles->getBundle(*I, true);
|
||||
unsigned ib = bundles->getBundle(B, false);
|
||||
unsigned ob = bundles->getBundle(B, true);
|
||||
activate(ib);
|
||||
activate(ob);
|
||||
nodes[ib].addBias(Freq, PrefSpill);
|
||||
@ -295,9 +293,7 @@ void SpillPlacement::addPrefSpill(ArrayRef<unsigned> Blocks, bool Strong) {
|
||||
}
|
||||
|
||||
void SpillPlacement::addLinks(ArrayRef<unsigned> Links) {
|
||||
for (ArrayRef<unsigned>::iterator I = Links.begin(), E = Links.end(); I != E;
|
||||
++I) {
|
||||
unsigned Number = *I;
|
||||
for (unsigned Number : Links) {
|
||||
unsigned ib = bundles->getBundle(Number, false);
|
||||
unsigned ob = bundles->getBundle(Number, true);
|
||||
|
||||
|
@ -1364,8 +1364,8 @@ void SplitEditor::rewriteAssigned(bool ExtendRanges) {
|
||||
|
||||
void SplitEditor::deleteRematVictims() {
|
||||
SmallVector<MachineInstr*, 8> Dead;
|
||||
for (LiveRangeEdit::iterator I = Edit->begin(), E = Edit->end(); I != E; ++I){
|
||||
LiveInterval *LI = &LIS.getInterval(*I);
|
||||
for (const Register &R : *Edit) {
|
||||
LiveInterval *LI = &LIS.getInterval(R);
|
||||
for (const LiveRange::Segment &S : LI->segments) {
|
||||
// Dead defs end at the dead slot.
|
||||
if (S.end != S.valno->def.getDeadSlot())
|
||||
|
@ -157,12 +157,8 @@ void StackSlotColoring::ScanForSpillSlotRefs(MachineFunction &MF) {
|
||||
SSRefs.resize(MFI->getObjectIndexEnd());
|
||||
|
||||
// FIXME: Need the equivalent of MachineRegisterInfo for frameindex operands.
|
||||
for (MachineFunction::iterator MBBI = MF.begin(), E = MF.end();
|
||||
MBBI != E; ++MBBI) {
|
||||
MachineBasicBlock *MBB = &*MBBI;
|
||||
for (MachineBasicBlock::iterator MII = MBB->begin(), EE = MBB->end();
|
||||
MII != EE; ++MII) {
|
||||
MachineInstr &MI = *MII;
|
||||
for (MachineBasicBlock &MBB : MF) {
|
||||
for (MachineInstr &MI : MBB) {
|
||||
for (unsigned i = 0, e = MI.getNumOperands(); i != e; ++i) {
|
||||
MachineOperand &MO = MI.getOperand(i);
|
||||
if (!MO.isFI())
|
||||
@ -474,9 +470,8 @@ bool StackSlotColoring::RemoveDeadStores(MachineBasicBlock* MBB) {
|
||||
++I;
|
||||
}
|
||||
|
||||
for (SmallVectorImpl<MachineInstr *>::iterator I = toErase.begin(),
|
||||
E = toErase.end(); I != E; ++I)
|
||||
(*I)->eraseFromParent();
|
||||
for (MachineInstr *MI : toErase)
|
||||
MI->eraseFromParent();
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
@ -1549,9 +1549,8 @@ bool TwoAddressInstructionPass::runOnMachineFunction(MachineFunction &Func) {
|
||||
.set(MachineFunctionProperties::Property::TiedOpsRewritten);
|
||||
|
||||
TiedOperandMap TiedOperands;
|
||||
for (MachineFunction::iterator MBBI = MF->begin(), MBBE = MF->end();
|
||||
MBBI != MBBE; ++MBBI) {
|
||||
MBB = &*MBBI;
|
||||
for (MachineBasicBlock &MBBI : *MF) {
|
||||
MBB = &MBBI;
|
||||
unsigned Dist = 0;
|
||||
DistanceMap.clear();
|
||||
SrcRegMap.clear();
|
||||
|
Loading…
Reference in New Issue
Block a user