aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-01-28 02:42:12 +0000
committerChris Lattner <sabre@nondot.org>2004-01-28 02:42:12 +0000
commit18348fe20155cbfd461bfc3a2a9d4b29d6be3ec2 (patch)
treeee43e20dbe0bb3e530f30692d998db73fb301285
parenta88a55cf104acca9265ceeeaf01cbc1b9ff6e772 (diff)
Pull the ScalarMap out into something that is more structured than what we had
before. This allows us to have a place to implement optimizations in a structured way. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10994 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/Analysis/DSGraph.h43
-rw-r--r--include/llvm/Analysis/DataStructure/DSGraph.h43
2 files changed, 84 insertions, 2 deletions
diff --git a/include/llvm/Analysis/DSGraph.h b/include/llvm/Analysis/DSGraph.h
index b4dcb51ec8..e81f139fb5 100644
--- a/include/llvm/Analysis/DSGraph.h
+++ b/include/llvm/Analysis/DSGraph.h
@@ -22,11 +22,52 @@ namespace llvm {
class GlobalValue;
//===----------------------------------------------------------------------===//
+/// DSScalarMap - An instance of this class is used to keep track of all of
+/// which DSNode each scalar in a function points to. This is specialized to
+/// keep track of globals with nodes in the function, and to keep track of the
+/// unique DSNodeHandle being used by the scalar map.
+///
+/// This class is crucial to the efficiency of DSA with some large SCC's. In
+/// these cases, the cost of iterating over the scalar map dominates the cost
+/// of DSA. In all of these cases, the DSA phase is really trying to identify
+/// globals or unique node handles active in the function.
+///
+
+class DSScalarMap {
+ typedef hash_map<Value*, DSNodeHandle> ValueMapTy;
+ ValueMapTy ValueMap;
+public:
+
+ // Compatibility methods: provide an interface compatible with a map of
+ // Value* to DSNodeHandle's.
+ typedef ValueMapTy::const_iterator const_iterator;
+ typedef ValueMapTy::iterator iterator;
+ iterator begin() { return ValueMap.begin(); }
+ iterator end() { return ValueMap.end(); }
+ const_iterator begin() const { return ValueMap.begin(); }
+ const_iterator end() const { return ValueMap.end(); }
+ iterator find(Value *V) { return ValueMap.find(V); }
+ const_iterator find(Value *V) const { return ValueMap.find(V); }
+ unsigned count(Value *V) const { return ValueMap.count(V); }
+
+ void erase(iterator I) { ValueMap.erase(I); }
+ void erase(Value *V) { ValueMap.erase(V); }
+
+ DSNodeHandle &operator[](Value *V) { return ValueMap[V]; }
+
+ void clear() {
+ ValueMap.clear();
+ }
+
+};
+
+
+//===----------------------------------------------------------------------===//
/// DSGraph - The graph that represents a function.
///
struct DSGraph {
// Public data-type declarations...
- typedef hash_map<Value*, DSNodeHandle> ScalarMapTy;
+ typedef DSScalarMap ScalarMapTy;
typedef hash_map<Function*, DSNodeHandle> ReturnNodesTy;
typedef hash_set<GlobalValue*> GlobalSetTy;
diff --git a/include/llvm/Analysis/DataStructure/DSGraph.h b/include/llvm/Analysis/DataStructure/DSGraph.h
index b4dcb51ec8..e81f139fb5 100644
--- a/include/llvm/Analysis/DataStructure/DSGraph.h
+++ b/include/llvm/Analysis/DataStructure/DSGraph.h
@@ -22,11 +22,52 @@ namespace llvm {
class GlobalValue;
//===----------------------------------------------------------------------===//
+/// DSScalarMap - An instance of this class is used to keep track of all of
+/// which DSNode each scalar in a function points to. This is specialized to
+/// keep track of globals with nodes in the function, and to keep track of the
+/// unique DSNodeHandle being used by the scalar map.
+///
+/// This class is crucial to the efficiency of DSA with some large SCC's. In
+/// these cases, the cost of iterating over the scalar map dominates the cost
+/// of DSA. In all of these cases, the DSA phase is really trying to identify
+/// globals or unique node handles active in the function.
+///
+
+class DSScalarMap {
+ typedef hash_map<Value*, DSNodeHandle> ValueMapTy;
+ ValueMapTy ValueMap;
+public:
+
+ // Compatibility methods: provide an interface compatible with a map of
+ // Value* to DSNodeHandle's.
+ typedef ValueMapTy::const_iterator const_iterator;
+ typedef ValueMapTy::iterator iterator;
+ iterator begin() { return ValueMap.begin(); }
+ iterator end() { return ValueMap.end(); }
+ const_iterator begin() const { return ValueMap.begin(); }
+ const_iterator end() const { return ValueMap.end(); }
+ iterator find(Value *V) { return ValueMap.find(V); }
+ const_iterator find(Value *V) const { return ValueMap.find(V); }
+ unsigned count(Value *V) const { return ValueMap.count(V); }
+
+ void erase(iterator I) { ValueMap.erase(I); }
+ void erase(Value *V) { ValueMap.erase(V); }
+
+ DSNodeHandle &operator[](Value *V) { return ValueMap[V]; }
+
+ void clear() {
+ ValueMap.clear();
+ }
+
+};
+
+
+//===----------------------------------------------------------------------===//
/// DSGraph - The graph that represents a function.
///
struct DSGraph {
// Public data-type declarations...
- typedef hash_map<Value*, DSNodeHandle> ScalarMapTy;
+ typedef DSScalarMap ScalarMapTy;
typedef hash_map<Function*, DSNodeHandle> ReturnNodesTy;
typedef hash_set<GlobalValue*> GlobalSetTy;