[llvm-commits] CVS: llvm/include/llvm/Analysis/DSGraph.h DSNode.h DSSupport.h DataStructure.h IPModRef.h

Chris Lattner lattner at cs.uiuc.edu
Fri Jan 31 22:53:03 PST 2003


Changes in directory llvm/include/llvm/Analysis:

DSGraph.h updated: 1.40 -> 1.41
DSNode.h updated: 1.18 -> 1.19
DSSupport.h updated: 1.9 -> 1.10
DataStructure.h updated: 1.60 -> 1.61
IPModRef.h updated: 1.8 -> 1.9

---
Log message:

Change DSGraph stuff to use hash_(set|map) instead of std::(set|map)
This change provides a small (3%) but consistent speedup


---
Diffs of the changes:

Index: llvm/include/llvm/Analysis/DSGraph.h
diff -u llvm/include/llvm/Analysis/DSGraph.h:1.40 llvm/include/llvm/Analysis/DSGraph.h:1.41
--- llvm/include/llvm/Analysis/DSGraph.h:1.40	Thu Jan 23 16:06:22 2003
+++ llvm/include/llvm/Analysis/DSGraph.h	Fri Jan 31 22:51:52 2003
@@ -19,7 +19,7 @@
 
   DSNodeHandle RetNode;    // The node that gets returned...
   std::vector<DSNode*> Nodes;
-  std::map<Value*, DSNodeHandle> ScalarMap;
+  hash_map<Value*, DSNodeHandle> ScalarMap;
 
   // FunctionCalls - This vector maintains a single entry for each call
   // instruction in the current graph.  The first entry in the vector is the
@@ -49,7 +49,7 @@
   // method.
   //
   DSGraph(const DSGraph &DSG);
-  DSGraph(const DSGraph &DSG, std::map<const DSNode*, DSNodeHandle> &NodeMap);
+  DSGraph(const DSGraph &DSG, hash_map<const DSNode*, DSNodeHandle> &NodeMap);
   ~DSGraph();
 
   bool hasFunction() const { return Func != 0; }
@@ -76,8 +76,8 @@
   /// getScalarMap - Get a map that describes what the nodes the scalars in this
   /// function point to...
   ///
-  std::map<Value*, DSNodeHandle> &getScalarMap() { return ScalarMap; }
-  const std::map<Value*, DSNodeHandle> &getScalarMap() const {return ScalarMap;}
+  hash_map<Value*, DSNodeHandle> &getScalarMap() { return ScalarMap; }
+  const hash_map<Value*, DSNodeHandle> &getScalarMap() const {return ScalarMap;}
 
   /// getFunctionCalls - Return the list of call sites in the original local
   /// graph...
@@ -102,7 +102,7 @@
   DSNodeHandle &getNodeForValue(Value *V) { return ScalarMap[V]; }
 
   const DSNodeHandle &getNodeForValue(Value *V) const {
-    std::map<Value*, DSNodeHandle>::const_iterator I = ScalarMap.find(V);
+    hash_map<Value*, DSNodeHandle>::const_iterator I = ScalarMap.find(V);
     assert(I != ScalarMap.end() &&
            "Use non-const lookup function if node may not be in the map");
     return I->second;
@@ -168,8 +168,8 @@
   // being cloned.
   //
   DSNodeHandle cloneInto(const DSGraph &G,
-                         std::map<Value*, DSNodeHandle> &OldValMap,
-                         std::map<const DSNode*, DSNodeHandle> &OldNodeMap,
+                         hash_map<Value*, DSNodeHandle> &OldValMap,
+                         hash_map<const DSNode*, DSNodeHandle> &OldNodeMap,
                          unsigned CloneFlags = 0);
 
   /// mergeInGraph - The method is used for merging graphs together.  If the


Index: llvm/include/llvm/Analysis/DSNode.h
diff -u llvm/include/llvm/Analysis/DSNode.h:1.18 llvm/include/llvm/Analysis/DSNode.h:1.19
--- llvm/include/llvm/Analysis/DSNode.h:1.18	Fri Jan 31 21:28:26 2003
+++ llvm/include/llvm/Analysis/DSNode.h	Fri Jan 31 22:51:53 2003
@@ -218,13 +218,13 @@
 
   /// remapLinks - Change all of the Links in the current node according to the
   /// specified mapping.
-  void remapLinks(std::map<const DSNode*, DSNodeHandle> &OldNodeMap);
+  void remapLinks(hash_map<const DSNode*, DSNodeHandle> &OldNodeMap);
 
   /// markReachableNodes - This method recursively traverses the specified
   /// DSNodes, marking any nodes which are reachable.  All reachable nodes it
   /// adds to the set, which allows it to only traverse visited nodes once.
   ///
-  void markReachableNodes(std::set<DSNode*> &ReachableNodes);
+  void markReachableNodes(hash_set<DSNode*> &ReachableNodes);
 
 private:
   friend class DSNodeHandle;


Index: llvm/include/llvm/Analysis/DSSupport.h
diff -u llvm/include/llvm/Analysis/DSSupport.h:1.9 llvm/include/llvm/Analysis/DSSupport.h:1.10
--- llvm/include/llvm/Analysis/DSSupport.h:1.9	Wed Jan 29 15:09:59 2003
+++ llvm/include/llvm/Analysis/DSSupport.h	Fri Jan 31 22:51:53 2003
@@ -8,10 +8,10 @@
 #define LLVM_ANALYSIS_DSSUPPORT_H
 
 #include <vector>
-#include <map>
-#include <set>
 #include <functional>
 #include <string>
+#include "Support/HashExtras.h"
+#include "Support/hash_set"
 
 class Function;
 class CallInst;
@@ -118,9 +118,9 @@
   Function    *ResolvingCaller;         // See comments above
 
   static void InitNH(DSNodeHandle &NH, const DSNodeHandle &Src,
-                     const std::map<const DSNode*, DSNode*> &NodeMap) {
+                     const hash_map<const DSNode*, DSNode*> &NodeMap) {
     if (DSNode *N = Src.getNode()) {
-      std::map<const DSNode*, DSNode*>::const_iterator I = NodeMap.find(N);
+      hash_map<const DSNode*, DSNode*>::const_iterator I = NodeMap.find(N);
       assert(I != NodeMap.end() && "Not not in mapping!");
 
       NH.setOffset(Src.getOffset());
@@ -129,9 +129,9 @@
   }
 
   static void InitNH(DSNodeHandle &NH, const DSNodeHandle &Src,
-                     const std::map<const DSNode*, DSNodeHandle> &NodeMap) {
+                     const hash_map<const DSNode*, DSNodeHandle> &NodeMap) {
     if (DSNode *N = Src.getNode()) {
-      std::map<const DSNode*, DSNodeHandle>::const_iterator I = NodeMap.find(N);
+      hash_map<const DSNode*, DSNodeHandle>::const_iterator I = NodeMap.find(N);
       assert(I != NodeMap.end() && "Not not in mapping!");
 
       NH.setOffset(Src.getOffset()+I->second.getOffset());
@@ -219,7 +219,7 @@
   /// DSNodes, marking any nodes which are reachable.  All reachable nodes it
   /// adds to the set, which allows it to only traverse visited nodes once.
   ///
-  void markReachableNodes(std::set<DSNode*> &Nodes);
+  void markReachableNodes(hash_set<DSNode*> &Nodes);
 
   bool operator<(const DSCallSite &CS) const {
     if (Callee < CS.Callee) return true;   // This must sort by callee first!


Index: llvm/include/llvm/Analysis/DataStructure.h
diff -u llvm/include/llvm/Analysis/DataStructure.h:1.60 llvm/include/llvm/Analysis/DataStructure.h:1.61
--- llvm/include/llvm/Analysis/DataStructure.h:1.60	Wed Dec 11 23:28:39 2002
+++ llvm/include/llvm/Analysis/DataStructure.h	Fri Jan 31 22:51:53 2003
@@ -8,7 +8,8 @@
 #define LLVM_ANALYSIS_DATA_STRUCTURE_H
 
 #include "llvm/Pass.h"
-#include <set>
+#include "Support/HashExtras.h"
+#include "Support/hash_set"
 
 class Type;
 class DSGraph;
@@ -32,7 +33,7 @@
 //
 class LocalDataStructures : public Pass {
   // DSInfo, one graph for each function
-  std::map<const Function*, DSGraph*> DSInfo;
+  hash_map<const Function*, DSGraph*> DSInfo;
   DSGraph *GlobalsGraph;
 public:
   ~LocalDataStructures() { releaseMemory(); }
@@ -45,7 +46,7 @@
 
   // getDSGraph - Return the data structure graph for the specified function.
   DSGraph &getDSGraph(const Function &F) const {
-    std::map<const Function*, DSGraph*>::const_iterator I = DSInfo.find(&F);
+    hash_map<const Function*, DSGraph*>::const_iterator I = DSInfo.find(&F);
     assert(I != DSInfo.end() && "Function not in module!");
     return *I->second;
   }
@@ -71,7 +72,7 @@
 //
 class BUDataStructures : public Pass {
   // DSInfo, one graph for each function
-  std::map<const Function*, DSGraph*> DSInfo;
+  hash_map<const Function*, DSGraph*> DSInfo;
   DSGraph *GlobalsGraph;
 public:
   ~BUDataStructures() { releaseMemory(); }
@@ -84,7 +85,7 @@
 
   // getDSGraph - Return the data structure graph for the specified function.
   DSGraph &getDSGraph(const Function &F) const {
-    std::map<const Function*, DSGraph*>::const_iterator I = DSInfo.find(&F);
+    hash_map<const Function*, DSGraph*>::const_iterator I = DSInfo.find(&F);
     assert(I != DSInfo.end() && "Function not in module!");
     return *I->second;
   }
@@ -110,10 +111,10 @@
   // functions IN the SCC at all.
   //
   DSGraph &inlineNonSCCGraphs(Function &F,
-                              std::set<Function*> &SCCFunctions);
+                              hash_set<Function*> &SCCFunctions);
  
   DSGraph &calculateSCCGraph(Function &F,
-                             std::set<Function*> &InlinedSCCFunctions);
+                             hash_set<Function*> &InlinedSCCFunctions);
   void calculateReachableGraphs(Function *F);
 
 
@@ -121,7 +122,7 @@
 
   unsigned calculateGraphs(Function *F, std::vector<Function*> &Stack,
                            unsigned &NextID, 
-                           std::map<Function*, unsigned> &ValMap);
+                           hash_map<Function*, unsigned> &ValMap);
 };
 
 
@@ -131,8 +132,8 @@
 //
 class TDDataStructures : public Pass {
   // DSInfo, one graph for each function
-  std::map<const Function*, DSGraph*> DSInfo;
-  std::set<const Function*> GraphDone;
+  hash_map<const Function*, DSGraph*> DSInfo;
+  hash_set<const Function*> GraphDone;
   DSGraph *GlobalsGraph;
 public:
   ~TDDataStructures() { releaseMemory(); }
@@ -145,7 +146,7 @@
 
   // getDSGraph - Return the data structure graph for the specified function.
   DSGraph &getDSGraph(const Function &F) const {
-    std::map<const Function*, DSGraph*>::const_iterator I = DSInfo.find(&F);
+    hash_map<const Function*, DSGraph*>::const_iterator I = DSInfo.find(&F);
     assert(I != DSInfo.end() && "Function not in module!");
     return *I->second;
   }


Index: llvm/include/llvm/Analysis/IPModRef.h
diff -u llvm/include/llvm/Analysis/IPModRef.h:1.8 llvm/include/llvm/Analysis/IPModRef.h:1.9
--- llvm/include/llvm/Analysis/IPModRef.h:1.8	Fri Dec  6 15:19:07 2002
+++ llvm/include/llvm/Analysis/IPModRef.h	Fri Jan 31 22:51:53 2003
@@ -41,6 +41,7 @@
 
 #include "llvm/Pass.h"
 #include "Support/BitSetVector.h"
+#include "Support/hash_map"
 
 class Module;
 class Function;
@@ -125,7 +126,7 @@
   void          computeModRef   (const Function &func);
   void          computeModRef   (const CallInst& callInst);
   DSGraph *ResolveCallSiteModRefInfo(CallInst &CI,
-                                std::map<const DSNode*, DSNodeHandle> &NodeMap);
+                                hash_map<const DSNode*, DSNodeHandle> &NodeMap);
 
 public:
   /* ctor */    FunctionModRefInfo      (const Function& func,





More information about the llvm-commits mailing list