From d12741e0a963ca6bf6d81c7e1fece1a0e01e2763 Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Sat, 24 Jan 2015 10:57:19 +0000 Subject: [PATCH] [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 --- llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp b/llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp index aa991faafea4..fa82d62b32f4 100644 --- a/llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp +++ b/llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp @@ -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(BB->getTerminator())) { + if (BranchInst *BI = dyn_cast(BB.getTerminator())) { if (handleBranchExpect(*BI)) IfHandled++; - } else if (SwitchInst *SI = dyn_cast(BB->getTerminator())) { + } else if (SwitchInst *SI = dyn_cast(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(BI++); if (!CI) continue;