[llvm-commits] CVS: llvm/include/llvm/Analysis/DataStructure/DSGraph.h DSNode.h DSSupport.h
Chris Lattner
lattner at cs.uiuc.edu
Sun Jan 30 15:51:04 PST 2005
Changes in directory llvm/include/llvm/Analysis/DataStructure:
DSGraph.h updated: 1.84 -> 1.85
DSNode.h updated: 1.48 -> 1.49
DSSupport.h updated: 1.35 -> 1.36
---
Log message:
* Make some methods more const correct.
* Change the FunctionCalls and AuxFunctionCalls vectors into std::lists.
This makes many operations on these lists much more natural, and avoids
*exteremely* expensive copying of DSCallSites (e.g. moving nodes around
between lists, erasing a node from not the end of the vector, etc).
With a profile build of analyze, this speeds up BU DS from 25.14s to
12.59s on 176.gcc. I expect that it would help TD even more, but I don't
have data for it.
This effectively eliminates removeIdenticalCalls and children from the
profile, going from 6.53 to 0.27s.
---
Diffs of the changes: (+23 -12)
DSGraph.h | 31 +++++++++++++++++++++----------
DSNode.h | 2 +-
DSSupport.h | 2 +-
3 files changed, 23 insertions(+), 12 deletions(-)
Index: llvm/include/llvm/Analysis/DataStructure/DSGraph.h
diff -u llvm/include/llvm/Analysis/DataStructure/DSGraph.h:1.84 llvm/include/llvm/Analysis/DataStructure/DSGraph.h:1.85
--- llvm/include/llvm/Analysis/DataStructure/DSGraph.h:1.84 Mon Jan 24 13:55:34 2005
+++ llvm/include/llvm/Analysis/DataStructure/DSGraph.h Sun Jan 30 17:50:48 2005
@@ -17,6 +17,7 @@
#include "llvm/Analysis/DataStructure/DSNode.h"
#include "llvm/ADT/hash_map"
+#include <list>
namespace llvm {
@@ -136,19 +137,19 @@
//
ReturnNodesTy ReturnNodes;
- // FunctionCalls - This vector maintains a single entry for each call
+ // FunctionCalls - This list maintains a single entry for each call
// instruction in the current graph. The first entry in the vector is the
// scalar that holds the return value for the call, the second is the function
// scalar being invoked, and the rest are pointer arguments to the function.
// This vector is built by the Local graph and is never modified after that.
//
- std::vector<DSCallSite> FunctionCalls;
+ std::list<DSCallSite> FunctionCalls;
// AuxFunctionCalls - This vector contains call sites that have been processed
// by some mechanism. In pratice, the BU Analysis uses this vector to hold
// the _unresolved_ call sites, because it cannot modify FunctionCalls.
//
- std::vector<DSCallSite> AuxFunctionCalls;
+ std::list<DSCallSite> AuxFunctionCalls;
// InlinedGlobals - This set records which globals have been inlined from
// other graphs (callers or callees, depending on the pass) into this one.
@@ -222,20 +223,30 @@
/// getFunctionCalls - Return the list of call sites in the original local
/// graph...
///
- const std::vector<DSCallSite> &getFunctionCalls() const {
- return FunctionCalls;
- }
+ const std::list<DSCallSite> &getFunctionCalls() const { return FunctionCalls;}
+ std::list<DSCallSite> &getFunctionCalls() { return FunctionCalls;}
/// getAuxFunctionCalls - Get the call sites as modified by whatever passes
/// have been run.
///
- std::vector<DSCallSite> &getAuxFunctionCalls() {
- return AuxFunctionCalls;
- }
- const std::vector<DSCallSite> &getAuxFunctionCalls() const {
+ std::list<DSCallSite> &getAuxFunctionCalls() { return AuxFunctionCalls; }
+ const std::list<DSCallSite> &getAuxFunctionCalls() const {
return AuxFunctionCalls;
}
+ // Function Call iteration
+ typedef std::list<DSCallSite>::const_iterator fc_iterator;
+ fc_iterator fc_begin() const { return FunctionCalls.begin(); }
+ fc_iterator fc_end() const { return FunctionCalls.end(); }
+
+
+ // Aux Function Call iteration
+ typedef std::list<DSCallSite>::const_iterator afc_iterator;
+ afc_iterator afc_begin() const { return AuxFunctionCalls.begin(); }
+ afc_iterator afc_end() const { return AuxFunctionCalls.end(); }
+
+
+
/// getInlinedGlobals - Get the set of globals that are have been inlined
/// (from callees in BU or from callers in TD) into the current graph.
///
Index: llvm/include/llvm/Analysis/DataStructure/DSNode.h
diff -u llvm/include/llvm/Analysis/DataStructure/DSNode.h:1.48 llvm/include/llvm/Analysis/DataStructure/DSNode.h:1.49
--- llvm/include/llvm/Analysis/DataStructure/DSNode.h:1.48 Sat Jan 29 18:08:36 2005
+++ llvm/include/llvm/Analysis/DataStructure/DSNode.h Sun Jan 30 17:50:48 2005
@@ -349,7 +349,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(hash_set<DSNode*> &ReachableNodes);
+ void markReachableNodes(hash_set<const DSNode*> &ReachableNodes) const;
private:
friend class DSNodeHandle;
Index: llvm/include/llvm/Analysis/DataStructure/DSSupport.h
diff -u llvm/include/llvm/Analysis/DataStructure/DSSupport.h:1.35 llvm/include/llvm/Analysis/DataStructure/DSSupport.h:1.36
--- llvm/include/llvm/Analysis/DataStructure/DSSupport.h:1.35 Sat Jan 8 22:18:28 2005
+++ llvm/include/llvm/Analysis/DataStructure/DSSupport.h Sun Jan 30 17:50:48 2005
@@ -289,7 +289,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(hash_set<DSNode*> &Nodes);
+ void markReachableNodes(hash_set<const DSNode*> &Nodes) const;
bool operator<(const DSCallSite &CS) const {
if (isDirectCall()) { // This must sort by callee first!
More information about the llvm-commits
mailing list