* 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19939 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2005-01-30 23:51:02 +00:00
parent 7b2a5270b7
commit a9548d9fd9
12 changed files with 271 additions and 235 deletions

View File

@@ -17,6 +17,7 @@
#include "llvm/Analysis/DataStructure/DSNode.h"
#include "llvm/ADT/hash_map"
#include <list>
namespace llvm {
@@ -136,19 +137,19 @@ private:
//
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 @@ public:
/// 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.
///

View File

@@ -349,7 +349,7 @@ public:
/// 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;

View File

@@ -289,7 +289,7 @@ public:
/// 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!