[llvm-commits] CVS: llvm-poolalloc/include/dsa/DSNode.h DataStructure.h

Andrew Lenharth alenhar2 at cs.uiuc.edu
Thu Apr 19 09:02:39 PDT 2007



Changes in directory llvm-poolalloc/include/dsa:

DSNode.h updated: 1.62 -> 1.63
DataStructure.h updated: 1.100 -> 1.101
---
Log message:

First algorithmic change.

This is partially to make kernel work easier, and partially to make poolalloc
better.

All functions, even externals (but not intrinsics) get graphs.  Graphs for
externals are such that they cause similar behavior to what is happening now,
namely that the args are marked as external, and no type inference happens, etc.

Then, recognizing libc functions is split into its own pass.  A similar pass
could be written for any work involving a set of known externals (aka the 
llva linux kernel work).  Thus the core DSA only knows about what is in llvm
proper.  (there is some regressions here, I didn't carry all the libc stuff over
into the new pass).

This helps PA, since inlining during BU is just dependent on the completeness
of the function pointer, not on the completeness and having no externals around.
One of the major problems with PA, functionality wise, is hitting functions that
haven't been resolved.  Inlining earlier tends to put enough information in each
node that BU based transforms get things right more often.  Still some issues here.

As a bonus, special case logic gets removed from some passes.

Also, externals like qsort can have graphs fabricated for them that
reflect their calls back into the program.



---
Diffs of the changes:  (+35 -12)

 DSNode.h        |    4 ++++
 DataStructure.h |   43 +++++++++++++++++++++++++++++++------------
 2 files changed, 35 insertions(+), 12 deletions(-)


Index: llvm-poolalloc/include/dsa/DSNode.h
diff -u llvm-poolalloc/include/dsa/DSNode.h:1.62 llvm-poolalloc/include/dsa/DSNode.h:1.63
--- llvm-poolalloc/include/dsa/DSNode.h:1.62	Tue Apr 17 18:41:06 2007
+++ llvm-poolalloc/include/dsa/DSNode.h	Thu Apr 19 11:02:19 2007
@@ -337,6 +337,10 @@
   ///
   unsigned getNodeFlags() const { return NodeType & ~DeadNode; }
 
+  /// clearNodeFlags - Useful for completely resetting a node, 
+  /// used in external recognizers
+  DSNode* clearNodeFlags() { NodeType = 0; return this; }
+
   bool isAllocaNode()     const { return NodeType & AllocaNode;    }
   bool isHeapNode()       const { return NodeType & HeapNode;      }
   bool isGlobalNode()     const { return NodeType & GlobalNode;    }


Index: llvm-poolalloc/include/dsa/DataStructure.h
diff -u llvm-poolalloc/include/dsa/DataStructure.h:1.100 llvm-poolalloc/include/dsa/DataStructure.h:1.101
--- llvm-poolalloc/include/dsa/DataStructure.h:1.100	Wed Apr 11 12:37:43 2007
+++ llvm-poolalloc/include/dsa/DataStructure.h	Thu Apr 19 11:02:19 2007
@@ -76,6 +76,8 @@
 
   void formGlobalECs();
 
+  DataStructures() :TD(0), GraphSource(0), GlobalsGraph(0) {}
+
 public:
 
   bool hasGraph(const Function &F) const {
@@ -114,6 +116,7 @@
 //
 class LocalDataStructures : public DataStructures {
 public:
+  LocalDataStructures() :DataStructures() {}
   ~LocalDataStructures() { releaseMemory(); }
 
   virtual bool runOnModule(Module &M);
@@ -135,6 +138,31 @@
   }
 };
 
+// StdLibDataStructures - This analysis recognizes common standard c library
+// functions and generates graphs for them.
+class StdLibDataStructures : public DataStructures {
+public:
+  StdLibDataStructures() :DataStructures() {}
+  ~StdLibDataStructures() { releaseMemory(); }
+
+  virtual bool runOnModule(Module &M);
+
+  /// print - Print out the analysis results...
+  ///
+  void print(std::ostream &O, const Module *M) const;
+
+  /// releaseMemory - if the pass pipeline is done with this pass, we can
+  /// release our memory...
+  ///
+  virtual void releaseMemory();
+
+  /// getAnalysisUsage - This obviously provides a data structure graph.
+  ///
+  virtual void getAnalysisUsage(AnalysisUsage &AU) const {
+    AU.setPreservesAll();
+    AU.addRequired<LocalDataStructures>();
+  }
+};
 
 /// BUDataStructures - The analysis that computes the interprocedurally closed
 /// data structure graphs for all of the functions in the program.  This pass
@@ -149,6 +177,7 @@
            std::pair<DSGraph*, std::vector<DSNodeHandle> > > *IndCallGraphMap;
 
 public:
+  BUDataStructures() : DataStructures() {}
   ~BUDataStructures() { releaseMyMemory(); }
 
   virtual bool runOnModule(Module &M);
@@ -170,7 +199,7 @@
 
   virtual void getAnalysisUsage(AnalysisUsage &AU) const {
     AU.setPreservesAll();
-    AU.addRequired<LocalDataStructures>();
+    AU.addRequired<StdLibDataStructures>();
   }
 
   typedef std::set<std::pair<Instruction*, Function*> > ActualCalleesTy;
@@ -232,20 +261,11 @@
   std::map<std::vector<Function*>, DSGraph*> IndCallMap;
 
 public:
+  TDDataStructures() :DataStructures() {}
   ~TDDataStructures() { releaseMyMemory(); }
 
   virtual bool runOnModule(Module &M);
 
-  /// 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));
-    if (I != DSInfo.end()) return *I->second;
-    return const_cast<TDDataStructures*>(this)->
-        getOrCreateDSGraph(const_cast<Function&>(F));
-  }
-
   /// deleteValue/copyValue - Interfaces to update the DSGraphs in the program.
   /// These correspond to the interfaces defined in the AliasAnalysis class.
   void deleteValue(Value *V);
@@ -271,7 +291,6 @@
                                                   hash_set<DSNode*> &Visited);
 
   void InlineCallersIntoGraph(DSGraph &G);
-  DSGraph &getOrCreateDSGraph(Function &F);
   void ComputePostOrder(Function &F, hash_set<DSGraph*> &Visited,
                         std::vector<DSGraph*> &PostOrder);
 };






More information about the llvm-commits mailing list