summaryrefslogtreecommitdiff
path: root/lib/Analysis
diff options
context:
space:
mode:
authorSumant Kowshik <kowshik@uiuc.edu>2003-08-05 17:04:41 +0000
committerSumant Kowshik <kowshik@uiuc.edu>2003-08-05 17:04:41 +0000
commit108421a8e55a5fa0236420fa9735c7fdc85bf4fe (patch)
treeb89300a5308c58aaf505cba9693450d660eca450 /lib/Analysis
parentf67e7fc7b18a794cdda9c0ff20739072ae41aaac (diff)
downloadllvm-108421a8e55a5fa0236420fa9735c7fdc85bf4fe.tar.gz
llvm-108421a8e55a5fa0236420fa9735c7fdc85bf4fe.tar.bz2
llvm-108421a8e55a5fa0236420fa9735c7fdc85bf4fe.tar.xz
Added function mergeInGlobalsGraph which merges in the entire globals graph with the graph of a function
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7606 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis')
-rw-r--r--lib/Analysis/DataStructure/DataStructure.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/Analysis/DataStructure/DataStructure.cpp b/lib/Analysis/DataStructure/DataStructure.cpp
index c25256a4fe..f930c0272e 100644
--- a/lib/Analysis/DataStructure/DataStructure.cpp
+++ b/lib/Analysis/DataStructure/DataStructure.cpp
@@ -1582,3 +1582,32 @@ void DSGraph::AssertGraphOK() const {
AssertAuxCallNodesInGraph();
}
+// A function useful for clients to incorporate the globals graph
+// into the DS, BU or TD graph for a function. This code retains
+// all globals, i.e., does not delete unreachable globals after they
+// are inlined.
+//
+void DSGraph::mergeInGlobalsGraph()
+{
+ NodeMapTy GlobalNodeMap;
+ ScalarMapTy OldValMap;
+ ReturnNodesTy OldRetNodes;
+ this->cloneInto(*GlobalsGraph, OldValMap, OldRetNodes, GlobalNodeMap,
+ DSGraph::KeepAllocaBit | DSGraph::DontCloneCallNodes |
+ DSGraph::DontCloneAuxCallNodes);
+
+ // Now merge existing global nodes in the GlobalsGraph with their copies
+ for (ScalarMapTy::iterator I = ScalarMap.begin(), E = ScalarMap.end();
+ I != E; ++I)
+ if (isa<GlobalValue>(I->first)) { // Found a global node
+ DSNodeHandle &GH = I->second;
+ DSNodeHandle &GGNodeH = GlobalsGraph->getScalarMap()[I->first];
+ GH.mergeWith(GlobalNodeMap[GGNodeH.getNode()]);
+ }
+
+ // Merging leaves behind unused nodes: get rid of them now.
+ GlobalNodeMap.clear();
+ OldValMap.clear();
+ OldRetNodes.clear();
+ removeTriviallyDeadNodes();
+}