The TargetData is not used for the isPowerOfTwo determination. It has never
[oota-llvm.git] / include / llvm / Analysis / ProfileInfo.h
index 80ba6d853345016d41ed064887a35dede5a42268..5d17fa1220e102cb33436c9df47a833aead0cfd3 100644 (file)
 #define LLVM_ANALYSIS_PROFILEINFO_H
 
 #include "llvm/Support/Debug.h"
+#include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/Format.h"
 #include "llvm/Support/raw_ostream.h"
 #include <cassert>
-#include <string>
 #include <map>
 #include <set>
+#include <string>
 
 namespace llvm {
   class Pass;
@@ -38,7 +39,7 @@ namespace llvm {
   class MachineBasicBlock;
   class MachineFunction;
 
-  // Helper for dumping edges to errs().
+  // Helper for dumping edges to dbgs().
   raw_ostream& operator<<(raw_ostream &O, std::pair<const BasicBlock *, const BasicBlock *> E);
   raw_ostream& operator<<(raw_ostream &O, std::pair<const MachineBasicBlock *, const MachineBasicBlock *> E);
 
@@ -85,13 +86,11 @@ namespace llvm {
 
     // getFunction() - Returns the Function for an Edge, checking for validity.
     static const FType* getFunction(Edge e) {
-      if (e.first) {
+      if (e.first)
         return e.first->getParent();
-      } else if (e.second) {
+      if (e.second)
         return e.second->getParent();
-      }
-      assert(0 && "Invalid ProfileInfo::Edge");
-      return (const FType*)0;
+      llvm_unreachable("Invalid ProfileInfo::Edge");
     }
 
     // getEdge() - Creates an Edge from two BasicBlocks.
@@ -123,7 +122,7 @@ namespace llvm {
 
     void setEdgeWeight(Edge e, double w) {
       DEBUG_WITH_TYPE("profile-info",
-            errs() << "Creating Edge " << e
+            dbgs() << "Creating Edge " << e
                    << " (weight: " << format("%.20g",w) << ")\n");
       EdgeInformation[getFunction(e)][e] = w;
     }
@@ -170,18 +169,18 @@ namespace llvm {
     void repair(const FType *F);
 
     void dump(FType *F = 0, bool real = true) {
-      errs() << "**** This is ProfileInfo " << this << " speaking:\n";
+      dbgs() << "**** This is ProfileInfo " << this << " speaking:\n";
       if (!real) {
         typename std::set<const FType*> Functions;
 
-        errs() << "Functions: \n";
+        dbgs() << "Functions: \n";
         if (F) {
-          errs() << F << "@" << format("%p", F) << ": " << format("%.20g",getExecutionCount(F)) << "\n";
+          dbgs() << F << "@" << format("%p", F) << ": " << format("%.20g",getExecutionCount(F)) << "\n";
           Functions.insert(F);
         } else {
           for (typename std::map<const FType*, double>::iterator fi = FunctionInformation.begin(),
                fe = FunctionInformation.end(); fi != fe; ++fi) {
-            errs() << fi->first << "@" << format("%p",fi->first) << ": " << format("%.20g",fi->second) << "\n";
+            dbgs() << fi->first << "@" << format("%p",fi->first) << ": " << format("%.20g",fi->second) << "\n";
             Functions.insert(fi->first);
           }
         }
@@ -190,34 +189,34 @@ namespace llvm {
              FI != FE; ++FI) {
           const FType *F = *FI;
           typename std::map<const FType*, BlockCounts>::iterator bwi = BlockInformation.find(F);
-          errs() << "BasicBlocks for Function " << F << ":\n";
+          dbgs() << "BasicBlocks for Function " << F << ":\n";
           for (typename BlockCounts::const_iterator bi = bwi->second.begin(), be = bwi->second.end(); bi != be; ++bi) {
-            errs() << bi->first << "@" << format("%p", bi->first) << ": " << format("%.20g",bi->second) << "\n";
+            dbgs() << bi->first << "@" << format("%p", bi->first) << ": " << format("%.20g",bi->second) << "\n";
           }
         }
 
         for (typename std::set<const FType*>::iterator FI = Functions.begin(), FE = Functions.end();
              FI != FE; ++FI) {
           typename std::map<const FType*, EdgeWeights>::iterator ei = EdgeInformation.find(*FI);
-          errs() << "Edges for Function " << ei->first << ":\n";
+          dbgs() << "Edges for Function " << ei->first << ":\n";
           for (typename EdgeWeights::iterator ewi = ei->second.begin(), ewe = ei->second.end(); 
                ewi != ewe; ++ewi) {
-            errs() << ewi->first << ": " << format("%.20g",ewi->second) << "\n";
+            dbgs() << ewi->first << ": " << format("%.20g",ewi->second) << "\n";
           }
         }
       } else {
         assert(F && "No function given, this is not supported!");
-        errs() << "Functions: \n";
-        errs() << F << "@" << format("%p", F) << ": " << format("%.20g",getExecutionCount(F)) << "\n";
+        dbgs() << "Functions: \n";
+        dbgs() << F << "@" << format("%p", F) << ": " << format("%.20g",getExecutionCount(F)) << "\n";
 
-        errs() << "BasicBlocks for Function " << F << ":\n";
+        dbgs() << "BasicBlocks for Function " << F << ":\n";
         for (typename FType::const_iterator BI = F->begin(), BE = F->end();
              BI != BE; ++BI) {
           const BType *BB = &(*BI);
-          errs() << BB << "@" << format("%p", BB) << ": " << format("%.20g",getExecutionCount(BB)) << "\n";
+          dbgs() << BB << "@" << format("%p", BB) << ": " << format("%.20g",getExecutionCount(BB)) << "\n";
         }
       }
-      errs() << "**** ProfileInfo " << this << ", over and out.\n";
+      dbgs() << "**** ProfileInfo " << this << ", over and out.\n";
     }
 
     bool CalculateMissingEdge(const BType *BB, Edge &removed, bool assumeEmptyExit = false);