Add GlobalDSGraph -- a common graph that holds externally visible nodes.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3173 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/DataStructure/Local.cpp b/lib/Analysis/DataStructure/Local.cpp
index 296195c..eb3d5b7 100644
--- a/lib/Analysis/DataStructure/Local.cpp
+++ b/lib/Analysis/DataStructure/Local.cpp
@@ -109,10 +109,14 @@
 //===----------------------------------------------------------------------===//
 // DSGraph constructor - Simply use the GraphBuilder to construct the local
 // graph.
-DSGraph::DSGraph(Function &F) : Func(F), RetNode(0) {
-  // Use the graph builder to construct the local version of the graph
-  GraphBuilder B(*this, Nodes, RetNode, ValueMap, FunctionCalls);
-  markIncompleteNodes();
+DSGraph::DSGraph(Function &F, GlobalDSGraph* GlobalsG)
+  : Func(F), RetNode(0), GlobalsGraph(GlobalsG) {
+  if (GlobalsGraph != this) {
+    GlobalsGraph->addReference(this);
+    // Use the graph builder to construct the local version of the graph
+    GraphBuilder B(*this, Nodes, RetNode, ValueMap, FunctionCalls);
+    markIncompleteNodes();
+  }
 }