diff options
author | Chris Lattner <sabre@nondot.org> | 2002-11-09 20:01:01 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-11-09 20:01:01 +0000 |
commit | 2e4f9bf86e5d3b86c4a24a58138c630c861d9def (patch) | |
tree | 711d268a9a871e39ee29db96aefee6716924610a /lib/Analysis/DataStructure | |
parent | d888893a54caeab7408e8015f7d4f423a2a4378a (diff) |
Add initial support for a globals graph
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4656 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/DataStructure')
-rw-r--r-- | lib/Analysis/DataStructure/DataStructure.cpp | 26 | ||||
-rw-r--r-- | lib/Analysis/DataStructure/Local.cpp | 8 |
2 files changed, 8 insertions, 26 deletions
diff --git a/lib/Analysis/DataStructure/DataStructure.cpp b/lib/Analysis/DataStructure/DataStructure.cpp index 6380a4967e..584031bade 100644 --- a/lib/Analysis/DataStructure/DataStructure.cpp +++ b/lib/Analysis/DataStructure/DataStructure.cpp @@ -501,14 +501,14 @@ Function &DSCallSite::getCaller() const { // DSGraph Implementation //===----------------------------------------------------------------------===// -DSGraph::DSGraph(const DSGraph &G) : Func(G.Func) { +DSGraph::DSGraph(const DSGraph &G) : Func(G.Func), GlobalsGraph(0) { std::map<const DSNode*, DSNodeHandle> NodeMap; RetNode = cloneInto(G, ScalarMap, NodeMap); } DSGraph::DSGraph(const DSGraph &G, std::map<const DSNode*, DSNodeHandle> &NodeMap) - : Func(G.Func) { + : Func(G.Func), GlobalsGraph(0) { RetNode = cloneInto(G, ScalarMap, NodeMap); } @@ -1056,28 +1056,6 @@ void DSGraph::maskNodeTypes(unsigned char Mask) { // GlobalDSGraph Implementation //===----------------------------------------------------------------------===// -GlobalDSGraph::GlobalDSGraph() : DSGraph(*(Function*)0, this) { -} - -GlobalDSGraph::~GlobalDSGraph() { - assert(Referrers.size() == 0 && - "Deleting global graph while references from other graphs exist"); -} - -void GlobalDSGraph::addReference(const DSGraph* referrer) { - if (referrer != this) - Referrers.insert(referrer); -} - -void GlobalDSGraph::removeReference(const DSGraph* referrer) { - if (referrer != this) { - assert(Referrers.find(referrer) != Referrers.end() && "This is very bad!"); - Referrers.erase(referrer); - if (Referrers.size() == 0) - delete this; - } -} - #if 0 // Bits used in the next function static const char ExternalTypeBits = DSNode::GlobalNode | DSNode::HeapNode; diff --git a/lib/Analysis/DataStructure/Local.cpp b/lib/Analysis/DataStructure/Local.cpp index 224ec4ab9c..0c0c6afd88 100644 --- a/lib/Analysis/DataStructure/Local.cpp +++ b/lib/Analysis/DataStructure/Local.cpp @@ -131,7 +131,7 @@ namespace { //===----------------------------------------------------------------------===// // DSGraph constructor - Simply use the GraphBuilder to construct the local // graph. -DSGraph::DSGraph(Function &F) : Func(&F) { +DSGraph::DSGraph(Function &F, DSGraph *GG) : Func(&F), GlobalsGraph(GG) { // Use the graph builder to construct the local version of the graph GraphBuilder B(*this, Nodes, RetNode, ScalarMap, FunctionCalls); markIncompleteNodes(); @@ -416,12 +416,16 @@ void LocalDataStructures::releaseMemory() { // Empty map so next time memory is released, data structures are not // re-deleted. DSInfo.clear(); + delete GlobalsGraph; + GlobalsGraph = 0; } bool LocalDataStructures::run(Module &M) { + GlobalsGraph = new DSGraph(); + // Calculate all of the graphs... for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) if (!I->isExternal()) - DSInfo.insert(std::make_pair(I, new DSGraph(*I))); + DSInfo.insert(std::make_pair(I, new DSGraph(*I, GlobalsGraph))); return false; } |