From cf15db34d3c0eecdc78fa958a73891b897cd2b02 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 17 Oct 2002 20:09:52 +0000 Subject: * Make the DSGraph cloner automatically merge global nodes * BUClosure doesn't have to worry about global nodes * TDClosure now works with global nodes * Reenable DNE on TD pass, now that globals work right git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4220 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/DataStructure/DataStructure.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'lib/Analysis/DataStructure/DataStructure.cpp') diff --git a/lib/Analysis/DataStructure/DataStructure.cpp b/lib/Analysis/DataStructure/DataStructure.cpp index 2418b0c657..2313cd09e8 100644 --- a/lib/Analysis/DataStructure/DataStructure.cpp +++ b/lib/Analysis/DataStructure/DataStructure.cpp @@ -439,14 +439,25 @@ DSNodeHandle DSGraph::cloneInto(const DSGraph &G, for (unsigned i = FN, e = Nodes.size(); i != e; ++i) Nodes[i]->NodeType &= ~StripBits; - // Copy the value map... + // Copy the value map... and merge all of the global nodes... for (std::map::const_iterator I = G.ValueMap.begin(), - E = G.ValueMap.end(); I != E; ++I) - OldValMap[I->first] = DSNodeHandle(OldNodeMap[I->second.getNode()], - I->second.getOffset()); + E = G.ValueMap.end(); I != E; ++I) { + DSNodeHandle &H = OldValMap[I->first]; + H = DSNodeHandle(OldNodeMap[I->second.getNode()], I->second.getOffset()); + + if (isa(I->first)) { // Is this a global? + std::map::iterator GVI = ValueMap.find(I->first); + if (GVI != ValueMap.end()) { // Is the global value in this fun already? + GVI->second.mergeWith(H); + } else { + ValueMap[I->first] = H; // Add global pointer to this graph + } + } + } // Copy the function calls list... CopyFunctionCallsList(G.FunctionCalls, FunctionCalls, OldNodeMap); + // Return the returned node pointer... return DSNodeHandle(OldNodeMap[G.RetNode.getNode()], G.RetNode.getOffset()); } -- cgit v1.2.3