Moved isDeclaration() check further down to allow for function counts for
authorAndreas Neustifter <astifter-llvm@gmx.at>
Wed, 26 Aug 2009 13:33:09 +0000 (13:33 +0000)
committerAndreas Neustifter <astifter-llvm@gmx.at>
Wed, 26 Aug 2009 13:33:09 +0000 (13:33 +0000)
declarations if necessary.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80084 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/ProfileInfo.cpp

index a7fc4c49d5ee2b36ffc386269c98bcd0b17e6dbd..fdbf03cc34d0068e0a14f02e1a68e06da7a332c0 100644 (file)
@@ -67,12 +67,15 @@ double ProfileInfo::getExecutionCount(const BasicBlock *BB) {
 }
 
 double ProfileInfo::getExecutionCount(const Function *F) {
-  if (F->isDeclaration()) return MissingValue;
   std::map<const Function*, double>::iterator J =
     FunctionInformation.find(F);
   if (J != FunctionInformation.end())
     return J->second;
 
+  // isDeclaration() is checked here and not at start of function to allow
+  // functions without a body still to have a execution count.
+  if (F->isDeclaration()) return MissingValue;
+
   double Count = getExecutionCount(&F->getEntryBlock());
   if (Count != MissingValue) FunctionInformation[F] = Count;
   return Count;