It's a bool, so treat it like one. Fixes a MSVC warning.
[oota-llvm.git] / lib / Analysis / ProfileInfo.cpp
index a7fc4c49d5ee2b36ffc386269c98bcd0b17e6dbd..55c5cab7510b8e1853f36ae630813a05de0e7947 100644 (file)
@@ -17,6 +17,7 @@
 #include "llvm/Pass.h"
 #include "llvm/Support/CFG.h"
 #include "llvm/Support/Compiler.h"
+#include "llvm/Support/raw_ostream.h"
 #include <set>
 using namespace llvm;
 
@@ -67,17 +68,27 @@ 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;
 }
 
+raw_ostream& llvm::operator<<(raw_ostream &O, ProfileInfo::Edge E) {
+  O << "(";
+  O << (E.first ? E.first->getNameStr() : "0");
+  O << ",";
+  O << (E.second ? E.second->getNameStr() : "0");
+  return O << ")";
+}
 
 //===----------------------------------------------------------------------===//
 //  NoProfile ProfileInfo implementation