We don't want to make this a pure interface, as it makes all implementors
authorChris Lattner <sabre@nondot.org>
Mon, 8 Mar 2004 21:30:18 +0000 (21:30 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 8 Mar 2004 21:30:18 +0000 (21:30 +0000)
bear the burden of implementing what will be all exactly the same methods.
They just want to provide the information in differing ways.

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

include/llvm/Analysis/ProfileInfo.h

index 10b31d5dede4f9072e2db26dab50abcc8fb38401..3bb056bf83d741e862d29968757b2e42a4285fd8 100644 (file)
@@ -22,6 +22,7 @@
 #define LLVM_ANALYSIS_PROFILEINFO_H
 
 #include <string>
+#include <map>
 
 namespace llvm {
   class BasicBlock;
@@ -32,13 +33,19 @@ namespace llvm {
   /// it available to the optimizers.
   Pass *createProfileLoaderPass(const std::string &Filename);
 
-  struct ProfileInfo {
+  class ProfileInfo {
+  protected:
+    std::map<BasicBlock*, unsigned> ExecutionCounts;
+  public:
     virtual ~ProfileInfo();  // We want to be subclassed
     
     //===------------------------------------------------------------------===//
     /// Profile Information Queries
     ///
-    virtual unsigned getExecutionCount(BasicBlock *BB) = 0;
+    unsigned getExecutionCount(BasicBlock *BB) {
+      std::map<BasicBlock*, unsigned>::iterator I = ExecutionCounts.find(BB);
+      return I != ExecutionCounts.end() ? I->second : 0;
+    }
     
     //===------------------------------------------------------------------===//
     /// Analysis Update Methods