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