diff options
author | David Majnemer <david.majnemer@gmail.com> | 2016-06-24 04:05:21 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2016-06-24 04:05:21 +0000 |
commit | d7708773288c4f33bf98c724f7a486b5973b8cc6 (patch) | |
tree | da2706e419335edde86f19e16552adcc1da3cd21 /llvm/lib/Transforms/Utils/SimplifyCFG.cpp | |
parent | 024402dcdf0c45b48b15d9a5de7f841e61e9bedc (diff) | |
download | bcm5719-llvm-d7708773288c4f33bf98c724f7a486b5973b8cc6.tar.gz bcm5719-llvm-d7708773288c4f33bf98c724f7a486b5973b8cc6.zip |
Switch more loops to be range-based
This makes the code a little more concise, no functional change is
intended.
llvm-svn: 273644
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyCFG.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp index 7c0f85c2ca1..6e1ac2c9a69 100644 --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -1534,25 +1534,25 @@ static Value *isSafeToSpeculateStore(Instruction *I, BasicBlock *BrBB, // Look for a store to the same pointer in BrBB. unsigned MaxNumInstToLookAt = 9; - for (BasicBlock::reverse_iterator RI = BrBB->rbegin(), RE = BrBB->rend(); - RI != RE && MaxNumInstToLookAt; ++RI) { - Instruction *CurI = &*RI; + for (Instruction &CurI : reverse(*BrBB)) { + if (!MaxNumInstToLookAt) + break; // Skip debug info. if (isa<DbgInfoIntrinsic>(CurI)) continue; --MaxNumInstToLookAt; // Could be calling an instruction that effects memory like free(). - if (CurI->mayHaveSideEffects() && !isa<StoreInst>(CurI)) + if (CurI.mayHaveSideEffects() && !isa<StoreInst>(CurI)) return nullptr; - StoreInst *SI = dyn_cast<StoreInst>(CurI); - // Found the previous store make sure it stores to the same location. - if (SI && SI->getPointerOperand() == StorePtr) - // Found the previous store, return its value operand. - return SI->getValueOperand(); - else if (SI) + if (auto *SI = dyn_cast<StoreInst>(&CurI)) { + // Found the previous store make sure it stores to the same location. + if (SI->getPointerOperand() == StorePtr) + // Found the previous store, return its value operand. + return SI->getValueOperand(); return nullptr; // Unknown store. + } } return nullptr; |