From 5999806dafb60f0dfc1b012234f906fdcf7f37d9 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226996 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/LowerExpectIntrinsic.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp b/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp index aa991faafea..fa82d62b32f 100644 --- a/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp +++ b/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;