mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-03-05 02:49:18 +00:00
Added function mergeInGlobalsGraph which merges in the entire globals graph with the graph of a function
llvm-svn: 7606
This commit is contained in:
parent
18c49a775f
commit
1a4fce3511
@ -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();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user