Expand the pass to unify all of the unwind blocks as well
[oota-llvm.git] / include / llvm / Analysis / DataStructure.h
index ebcc3c5c6456258a8295db22e8f6b7795ea7cfff..d8f30d25d09f9f92f30ed51a181f256b7a42672c 100644 (file)
@@ -8,10 +8,10 @@
 #define LLVM_ANALYSIS_DATA_STRUCTURE_H
 
 #include "llvm/Pass.h"
-#include "Support/HashExtras.h"
 #include "Support/hash_set"
 
 class Type;
+class CallInst;
 class DSGraph;
 class DSNode;
 class DSCallSite;
@@ -33,7 +33,7 @@ namespace DataStructureAnalysis {
 //
 class LocalDataStructures : public Pass {
   // DSInfo, one graph for each function
-  hash_map<const Function*, DSGraph*> DSInfo;
+  hash_map<Function*, DSGraph*> DSInfo;
   DSGraph *GlobalsGraph;
 public:
   ~LocalDataStructures() { releaseMemory(); }
@@ -41,12 +41,13 @@ public:
   virtual bool run(Module &M);
 
   bool hasGraph(const Function &F) const {
-    return DSInfo.find(&F) != DSInfo.end();
+    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<const Function*, DSGraph*>::const_iterator I = DSInfo.find(&F);
+    hash_map<Function*, DSGraph*>::const_iterator I =
+      DSInfo.find(const_cast<Function*>(&F));
     assert(I != DSInfo.end() && "Function not in module!");
     return *I->second;
   }
@@ -72,20 +73,22 @@ public:
 //
 class BUDataStructures : public Pass {
   // DSInfo, one graph for each function
-  hash_map<const Function*, DSGraph*> DSInfo;
+  hash_map<Function*, DSGraph*> DSInfo;
   DSGraph *GlobalsGraph;
+  hash_multimap<CallInst*, Function*> ActualCallees;
 public:
   ~BUDataStructures() { releaseMemory(); }
 
   virtual bool run(Module &M);
 
   bool hasGraph(const Function &F) const {
-    return DSInfo.find(&F) != DSInfo.end();
+    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<const Function*, DSGraph*>::const_iterator I = DSInfo.find(&F);
+    hash_map<Function*, DSGraph*>::const_iterator I =
+      DSInfo.find(const_cast<Function*>(&F));
     assert(I != DSInfo.end() && "Function not in module!");
     return *I->second;
   }
@@ -102,19 +105,15 @@ public:
     AU.setPreservesAll();
     AU.addRequired<LocalDataStructures>();
   }
+
+  typedef hash_multimap<CallInst*, Function*> ActualCalleesTy;
+  const ActualCalleesTy &getActualCallees() const {
+    return ActualCallees;
+  }
+
 private:
-  DSGraph &calculateGraph(Function &F);
+  void calculateGraph(DSGraph &G);
 
-  // inlineNonSCCGraphs - This method is almost like the other two calculate
-  // graph methods.  This one is used to inline function graphs (from functions
-  // outside of the SCC) into functions in the SCC.  It is not supposed to touch
-  // functions IN the SCC at all.
-  //
-  DSGraph &inlineNonSCCGraphs(Function &F,
-                              hash_set<Function*> &SCCFunctions);
-  DSGraph &calculateSCCGraph(Function &F,
-                             hash_set<Function*> &InlinedSCCFunctions);
   void calculateReachableGraphs(Function *F);
 
 
@@ -132,8 +131,8 @@ private:
 //
 class TDDataStructures : public Pass {
   // DSInfo, one graph for each function
-  hash_map<const Function*, DSGraph*> DSInfo;
-  hash_set<const Function*> GraphDone;
+  hash_map<Function*, DSGraph*> DSInfo;
+  hash_set<Function*> ArgsRemainIncomplete;
   DSGraph *GlobalsGraph;
 public:
   ~TDDataStructures() { releaseMyMemory(); }
@@ -141,12 +140,13 @@ public:
   virtual bool run(Module &M);
 
   bool hasGraph(const Function &F) const {
-    return DSInfo.find(&F) != DSInfo.end();
+    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<const Function*, DSGraph*>::const_iterator I = DSInfo.find(&F);
+    hash_map<Function*, DSGraph*>::const_iterator I =
+      DSInfo.find(const_cast<Function*>(&F));
     assert(I != DSInfo.end() && "Function not in module!");
     return *I->second;
   }
@@ -166,10 +166,11 @@ public:
   }
 
 private:
-  void calculateGraph(Function &F);
+  void inlineGraphIntoCallees(DSGraph &G);
   DSGraph &getOrCreateDSGraph(Function &F);
-
-  void ResolveCallSite(DSGraph &Graph, const DSCallSite &CallSite);
+  void ComputePostOrder(Function &F, hash_set<DSGraph*> &Visited,
+                        std::vector<DSGraph*> &PostOrder,
+                        const BUDataStructures::ActualCalleesTy &ActualCallees);
 };
 
 #endif