Add an initial version of the CompleteBUDataStructures pass
authorChris Lattner <sabre@nondot.org>
Thu, 13 Nov 2003 01:42:38 +0000 (01:42 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 13 Nov 2003 01:42:38 +0000 (01:42 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9955 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Analysis/DataStructure.h
include/llvm/Analysis/DataStructure/DataStructure.h

index 4d6e3a047604326976721f2fc754ebdbb6cc4510..3e57af21318aadcd3321e640a7f0e766cd74accf 100644 (file)
@@ -82,6 +82,7 @@ public:
 // only performs a "Bottom Up" propagation (hence the name).
 //
 class BUDataStructures : public Pass {
+protected:
   // DSInfo, one graph for each function
   hash_map<Function*, DSGraph*> DSInfo;
   DSGraph *GlobalsGraph;
@@ -186,6 +187,39 @@ private:
                         const BUDataStructures::ActualCalleesTy &ActualCallees);
 };
 
+
+// CompleteBUDataStructures - This is the exact same as the bottom-up graphs,
+// but we use take a completed call graph and inline all indirect callees into
+// their callers graphs, making the result more useful for things like pool
+// allocation.
+//
+struct CompleteBUDataStructures : public BUDataStructures {
+  virtual bool run(Module &M);
+
+  bool hasGraph(const Function &F) const {
+    return DSInfo.find(const_cast<Function*>(&F)) != DSInfo.end();
+  }
+
+  // getDSGraph - Return the data structure graph for the specified function.
+  DSGraph &getDSGraph(const Function &F) const {
+    hash_map<Function*, DSGraph*>::const_iterator I =
+      DSInfo.find(const_cast<Function*>(&F));
+    assert(I != DSInfo.end() && "Function not in module!");
+    return *I->second;
+  }
+
+  virtual void getAnalysisUsage(AnalysisUsage &AU) const {
+    AU.setPreservesAll();
+    AU.addRequired<BUDataStructures>();
+
+    // FIXME: TEMPORARY (remove once finalization of indirect call sites in the
+    // globals graph has been implemented in the BU pass)
+    AU.addRequired<TDDataStructures>();
+  }
+};
+
+
+
 } // End llvm namespace
 
 #endif
index 4d6e3a047604326976721f2fc754ebdbb6cc4510..3e57af21318aadcd3321e640a7f0e766cd74accf 100644 (file)
@@ -82,6 +82,7 @@ public:
 // only performs a "Bottom Up" propagation (hence the name).
 //
 class BUDataStructures : public Pass {
+protected:
   // DSInfo, one graph for each function
   hash_map<Function*, DSGraph*> DSInfo;
   DSGraph *GlobalsGraph;
@@ -186,6 +187,39 @@ private:
                         const BUDataStructures::ActualCalleesTy &ActualCallees);
 };
 
+
+// CompleteBUDataStructures - This is the exact same as the bottom-up graphs,
+// but we use take a completed call graph and inline all indirect callees into
+// their callers graphs, making the result more useful for things like pool
+// allocation.
+//
+struct CompleteBUDataStructures : public BUDataStructures {
+  virtual bool run(Module &M);
+
+  bool hasGraph(const Function &F) const {
+    return DSInfo.find(const_cast<Function*>(&F)) != DSInfo.end();
+  }
+
+  // getDSGraph - Return the data structure graph for the specified function.
+  DSGraph &getDSGraph(const Function &F) const {
+    hash_map<Function*, DSGraph*>::const_iterator I =
+      DSInfo.find(const_cast<Function*>(&F));
+    assert(I != DSInfo.end() && "Function not in module!");
+    return *I->second;
+  }
+
+  virtual void getAnalysisUsage(AnalysisUsage &AU) const {
+    AU.setPreservesAll();
+    AU.addRequired<BUDataStructures>();
+
+    // FIXME: TEMPORARY (remove once finalization of indirect call sites in the
+    // globals graph has been implemented in the BU pass)
+    AU.addRequired<TDDataStructures>();
+  }
+};
+
+
+
 } // End llvm namespace
 
 #endif