[PM] Switch tihs code to use a range based for loop over the function.

We can't switch the loop over the instructions because it needs to
early-increment the iterator.

llvm-svn: 226996
This commit is contained in:
Chandler Carruth 2015-01-24 10:57:19 +00:00
parent 3f5e7b1fb6
commit d12741e0a9
1 changed files with 4 additions and 6 deletions

View File

@ -143,20 +143,18 @@ static bool handleBranchExpect(BranchInst &BI) {
}
bool LowerExpectIntrinsic::runOnFunction(Function &F) {
for (Function::iterator I = F.begin(), E = F.end(); I != E;) {
BasicBlock *BB = I++;
for (BasicBlock &BB : F) {
// Create "block_weights" metadata.
if (BranchInst *BI = dyn_cast<BranchInst>(BB->getTerminator())) {
if (BranchInst *BI = dyn_cast<BranchInst>(BB.getTerminator())) {
if (handleBranchExpect(*BI))
IfHandled++;
} else if (SwitchInst *SI = dyn_cast<SwitchInst>(BB->getTerminator())) {
} else if (SwitchInst *SI = dyn_cast<SwitchInst>(BB.getTerminator())) {
if (handleSwitchExpect(*SI))
IfHandled++;
}
// remove llvm.expect intrinsics.
for (BasicBlock::iterator BI = BB->begin(), BE = BB->end(); BI != BE;) {
for (BasicBlock::iterator BI = BB.begin(), BE = BB.end(); BI != BE;) {
CallInst *CI = dyn_cast<CallInst>(BI++);
if (!CI)
continue;