diff options
author | Sumant Kowshik <kowshik@uiuc.edu> | 2003-08-05 17:04:41 +0000 |
---|---|---|
committer | Sumant Kowshik <kowshik@uiuc.edu> | 2003-08-05 17:04:41 +0000 |
commit | 1d869b78f584c6e68e680c13d4a1d2aefdcba342 (patch) | |
tree | 1716006a98baf56cac186a597b2505f1c06b59a5 /llvm/lib/Analysis/DataStructure/DataStructure.cpp | |
parent | 0383a65103e53a0c8cc6b7ad007a620fe96cf3a9 (diff) | |
download | bcm5719-llvm-1d869b78f584c6e68e680c13d4a1d2aefdcba342.tar.gz bcm5719-llvm-1d869b78f584c6e68e680c13d4a1d2aefdcba342.zip |
Added function mergeInGlobalsGraph which merges in the entire globals graph with the graph of a function
llvm-svn: 7606
Diffstat (limited to 'llvm/lib/Analysis/DataStructure/DataStructure.cpp')
-rw-r--r-- | llvm/lib/Analysis/DataStructure/DataStructure.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/DataStructure/DataStructure.cpp b/llvm/lib/Analysis/DataStructure/DataStructure.cpp index c25256a4fed..f930c0272ed 100644 --- a/llvm/lib/Analysis/DataStructure/DataStructure.cpp +++ b/llvm/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(); +} |