From 01095a5d43bbfde13731688ddcf6048ebb8b7721 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Sat, 23 Jul 2016 20:41:05 +0000 Subject: Vendor import of llvm release_39 branch r276489: https://llvm.org/svn/llvm-project/llvm/branches/release_39@276489 --- lib/Analysis/CodeMetrics.cpp | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'lib/Analysis/CodeMetrics.cpp') diff --git a/lib/Analysis/CodeMetrics.cpp b/lib/Analysis/CodeMetrics.cpp index 4090b4cd752b..ed8370498dd0 100644 --- a/lib/Analysis/CodeMetrics.cpp +++ b/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 &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(II) || isa(II)) { - ImmutableCallSite CS(cast(II)); + if (isa(I) || isa(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,26 +140,29 @@ void CodeMetrics::analyzeBasicBlock(const BasicBlock *BB, } } - if (const AllocaInst *AI = dyn_cast(II)) { + if (const AllocaInst *AI = dyn_cast(&I)) { if (!AI->isStaticAlloca()) this->usesDynamicAlloca = true; } - if (isa(II) || II->getType()->isVectorTy()) + if (isa(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(II)) + if (const CallInst *CI = dyn_cast(&I)) { if (CI->cannotDuplicate()) notDuplicatable = true; + if (CI->isConvergent()) + convergent = true; + } - if (const InvokeInst *InvI = dyn_cast(II)) + if (const InvokeInst *InvI = dyn_cast(&I)) if (InvI->cannotDuplicate()) notDuplicatable = true; - NumInsts += TTI.getUserCost(&*II); + NumInsts += TTI.getUserCost(&I); } if (isa(BB->getTerminator())) -- cgit v1.2.3