summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2015-02-18 08:19:16 +0000
committerDaniel Jasper <djasper@google.com>2015-02-18 08:19:16 +0000
commited9eb7209e21354a00f07c72381e852b68626ede (patch)
treeed9a27e19c1a1cdb33ec4e2b48b3cec73c420c59 /llvm/lib
parent4d7b04384e09ada2c8bf5716b429f72b7a00848e (diff)
downloadbcm5719-llvm-ed9eb7209e21354a00f07c72381e852b68626ede.tar.gz
bcm5719-llvm-ed9eb7209e21354a00f07c72381e852b68626ede.zip
NFC: Use range-based for loops and more consistent naming.
No functional changes intended. (I plan on doing some modifications to this function and would like to have as few unrelated changes as possible in the patch) llvm-svn: 229649
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/CodeGen/MachineBlockPlacement.cpp34
1 files changed, 15 insertions, 19 deletions
diff --git a/llvm/lib/CodeGen/MachineBlockPlacement.cpp b/llvm/lib/CodeGen/MachineBlockPlacement.cpp
index d7aee575882..1b5c1f1f881 100644
--- a/llvm/lib/CodeGen/MachineBlockPlacement.cpp
+++ b/llvm/lib/CodeGen/MachineBlockPlacement.cpp
@@ -347,29 +347,27 @@ MachineBasicBlock *MachineBlockPlacement::selectBestSuccessor(
uint32_t WeightScale = 0;
uint32_t SumWeight = MBPI->getSumForBlock(BB, WeightScale);
DEBUG(dbgs() << "Attempting merge from: " << getBlockName(BB) << "\n");
- for (MachineBasicBlock::succ_iterator SI = BB->succ_begin(),
- SE = BB->succ_end();
- SI != SE; ++SI) {
- if (BlockFilter && !BlockFilter->count(*SI))
+ for (MachineBasicBlock *Succ : BB->successors()) {
+ if (BlockFilter && !BlockFilter->count(Succ))
continue;
- BlockChain &SuccChain = *BlockToChain[*SI];
+ BlockChain &SuccChain = *BlockToChain[Succ];
if (&SuccChain == &Chain) {
- DEBUG(dbgs() << " " << getBlockName(*SI) << " -> Already merged!\n");
+ DEBUG(dbgs() << " " << getBlockName(Succ) << " -> Already merged!\n");
continue;
}
- if (*SI != *SuccChain.begin()) {
- DEBUG(dbgs() << " " << getBlockName(*SI) << " -> Mid chain!\n");
+ if (Succ != *SuccChain.begin()) {
+ DEBUG(dbgs() << " " << getBlockName(Succ) << " -> Mid chain!\n");
continue;
}
- uint32_t SuccWeight = MBPI->getEdgeWeight(BB, *SI);
+ uint32_t SuccWeight = MBPI->getEdgeWeight(BB, Succ);
BranchProbability SuccProb(SuccWeight / WeightScale, SumWeight);
// Only consider successors which are either "hot", or wouldn't violate
// any CFG constraints.
if (SuccChain.LoopPredecessors != 0) {
if (SuccProb < HotProb) {
- DEBUG(dbgs() << " " << getBlockName(*SI) << " -> " << SuccProb
+ DEBUG(dbgs() << " " << getBlockName(Succ) << " -> " << SuccProb
<< " (prob) (CFG conflict)\n");
continue;
}
@@ -379,33 +377,31 @@ MachineBasicBlock *MachineBlockPlacement::selectBestSuccessor(
BlockFrequency CandidateEdgeFreq =
MBFI->getBlockFreq(BB) * SuccProb * HotProb.getCompl();
bool BadCFGConflict = false;
- for (MachineBasicBlock::pred_iterator PI = (*SI)->pred_begin(),
- PE = (*SI)->pred_end();
- PI != PE; ++PI) {
- if (*PI == *SI || (BlockFilter && !BlockFilter->count(*PI)) ||
- BlockToChain[*PI] == &Chain)
+ for (MachineBasicBlock *Pred : Succ->predecessors()) {
+ if (Pred == Succ || (BlockFilter && !BlockFilter->count(Pred)) ||
+ BlockToChain[Pred] == &Chain)
continue;
BlockFrequency PredEdgeFreq =
- MBFI->getBlockFreq(*PI) * MBPI->getEdgeProbability(*PI, *SI);
+ MBFI->getBlockFreq(Pred) * MBPI->getEdgeProbability(Pred, Succ);
if (PredEdgeFreq >= CandidateEdgeFreq) {
BadCFGConflict = true;
break;
}
}
if (BadCFGConflict) {
- DEBUG(dbgs() << " " << getBlockName(*SI) << " -> " << SuccProb
+ DEBUG(dbgs() << " " << getBlockName(Succ) << " -> " << SuccProb
<< " (prob) (non-cold CFG conflict)\n");
continue;
}
}
- DEBUG(dbgs() << " " << getBlockName(*SI) << " -> " << SuccProb
+ DEBUG(dbgs() << " " << getBlockName(Succ) << " -> " << SuccProb
<< " (prob)"
<< (SuccChain.LoopPredecessors != 0 ? " (CFG break)" : "")
<< "\n");
if (BestSucc && BestWeight >= SuccWeight)
continue;
- BestSucc = *SI;
+ BestSucc = Succ;
BestWeight = SuccWeight;
}
return BestSucc;
OpenPOWER on IntegriCloud