BlockChain *MachineBlockPlacement::CreateChain(MachineBasicBlock *BB) {
BlockChain *Chain =
new (ChainAllocator.Allocate()) BlockChain(BlockToChain, BB);
- //assert(ActiveChains.insert(Chain));
return Chain;
}
return;
// Walk through the successors looking for the highest probability edge.
- // FIXME: This is an annoying way to do the comparison, but it's correct.
- // Support should be added to BranchProbability to properly compare two.
MachineBasicBlock *Successor = 0;
- BlockFrequency BestFreq;
+ BranchProbability BestProb = BranchProbability::getZero();
DEBUG(dbgs() << "Attempting merge from: " << getBlockName(BB) << "\n");
for (MachineBasicBlock::succ_iterator SI = BB->succ_begin(),
SE = BB->succ_end();
if (BB == *SI || (Filter && !Filter->count(*SI)))
continue;
- BlockFrequency SuccFreq(BlockFrequency::getEntryFrequency());
- SuccFreq *= MBPI->getEdgeProbability(BB, *SI);
- DEBUG(dbgs() << " " << getBlockName(*SI) << " -> " << SuccFreq << "\n");
- if (!Successor || SuccFreq > BestFreq || (!(SuccFreq < BestFreq) &&
+ BranchProbability SuccProb = MBPI->getEdgeProbability(BB, *SI);
+ DEBUG(dbgs() << " " << getBlockName(*SI) << " -> " << SuccProb << "\n");
+ if (!Successor || SuccProb > BestProb || (!(SuccProb < BestProb) &&
BB->isLayoutSuccessor(*SI))) {
Successor = *SI;
- BestFreq = SuccFreq;
+ BestProb = SuccProb;
}
}
if (!Successor)
void MachineBlockPlacement::placeChainsTopologically(MachineFunction &F) {
MachineBasicBlock *EntryB = &F.front();
- BlockChain *EntryChain = BlockToChain[EntryB];
- assert(EntryChain && "Missing chain for entry block");
- assert(*EntryChain->begin() == EntryB &&
+ assert(BlockToChain[EntryB] && "Missing chain for entry block");
+ assert(*BlockToChain[EntryB]->begin() == EntryB &&
"Entry block is not the head of the entry block chain");
// Walk the blocks in RPO, and insert each block for a chain in order the