[llvm] r226996 - [PM] Switch tihs code to use a range based for loop over the function.
Chandler Carruth
chandlerc at gmail.com
Sat Jan 24 02:57:22 PST 2015
Author: chandlerc
Date: Sat Jan 24 04:57:19 2015
New Revision: 226996
URL: http://llvm.org/viewvc/llvm-project?rev=226996&view=rev
Log:
[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.
Modified:
llvm/trunk/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp?rev=226996&r1=226995&r2=226996&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp Sat Jan 24 04:57:19 2015
@@ -143,20 +143,18 @@ static bool handleBranchExpect(BranchIns
}
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;
More information about the llvm-commits
mailing list