aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/CodeMetrics.cpp
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2016-03-08 20:53:48 +0000
committerSanjay Patel <spatel@rotateright.com>2016-03-08 20:53:48 +0000
commitb8d071bc8a542680e56eb769313380ada12f1546 (patch)
tree94ccacb4461cb85e72249a33176d0743e11dda7f /llvm/lib/Analysis/CodeMetrics.cpp
parent1f04c4488501deed5b6bfac098815bec14b8bb73 (diff)
downloadllvm-b8d071bc8a542680e56eb769313380ada12f1546.zip
llvm-b8d071bc8a542680e56eb769313380ada12f1546.tar.gz
llvm-b8d071bc8a542680e56eb769313380ada12f1546.tar.bz2
use range-based for loop; NFCI
llvm-svn: 262956
Diffstat (limited to 'llvm/lib/Analysis/CodeMetrics.cpp')
-rw-r--r--llvm/lib/Analysis/CodeMetrics.cpp25
1 files changed, 12 insertions, 13 deletions
diff --git a/llvm/lib/Analysis/CodeMetrics.cpp b/llvm/lib/Analysis/CodeMetrics.cpp
index 035717a..ed83704 100644
--- a/llvm/lib/Analysis/CodeMetrics.cpp
+++ b/llvm/lib/Analysis/CodeMetrics.cpp
@@ -100,22 +100,21 @@ void CodeMetrics::collectEphemeralValues(
completeEphemeralValues(WorkSet, EphValues);
}
-/// analyzeBasicBlock - Fill in the current structure with information gleaned
-/// from the specified block.
+/// Fill in the current structure with information gleaned from the specified
+/// block.
void CodeMetrics::analyzeBasicBlock(const BasicBlock *BB,
const TargetTransformInfo &TTI,
SmallPtrSetImpl<const Value*> &EphValues) {
++NumBlocks;
unsigned NumInstsBeforeThisBB = NumInsts;
- for (BasicBlock::const_iterator II = BB->begin(), E = BB->end();
- II != E; ++II) {
+ for (const Instruction &I : *BB) {
// Skip ephemeral values.
- if (EphValues.count(&*II))
+ if (EphValues.count(&I))
continue;
// Special handling for calls.
- if (isa<CallInst>(II) || isa<InvokeInst>(II)) {
- ImmutableCallSite CS(cast<Instruction>(II));
+ if (isa<CallInst>(I) || isa<InvokeInst>(I)) {
+ ImmutableCallSite CS(&I);
if (const Function *F = CS.getCalledFunction()) {
// If a function is both internal and has a single use, then it is
@@ -141,29 +140,29 @@ void CodeMetrics::analyzeBasicBlock(const BasicBlock *BB,
}
}
- if (const AllocaInst *AI = dyn_cast<AllocaInst>(II)) {
+ if (const AllocaInst *AI = dyn_cast<AllocaInst>(&I)) {
if (!AI->isStaticAlloca())
this->usesDynamicAlloca = true;
}
- if (isa<ExtractElementInst>(II) || II->getType()->isVectorTy())
+ if (isa<ExtractElementInst>(I) || I.getType()->isVectorTy())
++NumVectorInsts;
- if (II->getType()->isTokenTy() && II->isUsedOutsideOfBlock(BB))
+ if (I.getType()->isTokenTy() && I.isUsedOutsideOfBlock(BB))
notDuplicatable = true;
- if (const CallInst *CI = dyn_cast<CallInst>(II)) {
+ if (const CallInst *CI = dyn_cast<CallInst>(&I)) {
if (CI->cannotDuplicate())
notDuplicatable = true;
if (CI->isConvergent())
convergent = true;
}
- if (const InvokeInst *InvI = dyn_cast<InvokeInst>(II))
+ if (const InvokeInst *InvI = dyn_cast<InvokeInst>(&I))
if (InvI->cannotDuplicate())
notDuplicatable = true;
- NumInsts += TTI.getUserCost(&*II);
+ NumInsts += TTI.getUserCost(&I);
}
if (isa<ReturnInst>(BB->getTerminator()))