diff options
author | Chris Lattner <sabre@nondot.org> | 2002-04-16 20:39:59 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-04-16 20:39:59 +0000 |
commit | 7650b94c758f55066b43799ecfb50c729c2153af (patch) | |
tree | 29f836dd25a5cd09c714055a0e00ce1e8bb5256b /lib/Analysis/DataStructure/EliminateNodes.cpp | |
parent | 28c238636ea663419f35319bcedc445d08995e57 (diff) |
* Remove the concept of a critical shadow node
* Make the function pointer argument explicit for a call nodes
* Eliminate unreachable global values
* Merge call nodes that are identical
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2266 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/DataStructure/EliminateNodes.cpp')
-rw-r--r-- | lib/Analysis/DataStructure/EliminateNodes.cpp | 47 |
1 files changed, 22 insertions, 25 deletions
diff --git a/lib/Analysis/DataStructure/EliminateNodes.cpp b/lib/Analysis/DataStructure/EliminateNodes.cpp index 6b22f69617..edd8285bc8 100644 --- a/lib/Analysis/DataStructure/EliminateNodes.cpp +++ b/lib/Analysis/DataStructure/EliminateNodes.cpp @@ -53,23 +53,6 @@ static void DestroyFirstNodeOfPair(DSNode *N1, DSNode *N2) { assert(RanOnce && "Node on user set but cannot find the use!"); } - // If we are about to eliminate a call node that returns a pointer, make the - // shadow node it points to not be critical anymore! - // - if (isa<CallDSNode>(N1) && N1->getNumLinks()) { - assert(N1->getNumLinks() == 1 && "Call node can only return one pointer!"); - PointerValSet &PVS = N1->getLink(0); - - for (unsigned i = 0, e = PVS.size(); i != e; ++i) - if (ShadowDSNode *Shad = dyn_cast<ShadowDSNode>(PVS[i].Node)) - if (Shad->isCriticalNode()) { - Shad->resetCriticalMark(); // Only unmark _ONE_ node.. - break; - } - - } - - N1->removeAllIncomingEdges(); delete N1; } @@ -80,9 +63,10 @@ static void DestroyFirstNodeOfPair(DSNode *N1, DSNode *N2) { // static bool isIndistinguishableNode(DSNode *DN) { if (DN->getReferrers().empty()) { // No referrers... - if (isa<ShadowDSNode>(DN) || isa<AllocDSNode>(DN)) + if (isa<ShadowDSNode>(DN) || isa<AllocDSNode>(DN)) { + delete DN; return true; // Node is trivially dead - else + } else return false; } @@ -328,17 +312,30 @@ bool FunctionDSGraph::RemoveUnreachableNodes() { } } - // Loop over the global nodes, removing nodes that have no edges into them. - // + // Loop over the global nodes, removing nodes that have no edges into them or + // out of them. + // for (std::vector<GlobalDSNode*>::iterator I = GlobalNodes.begin(); I != GlobalNodes.end(); ) - if ((*I)->getReferrers().empty()) { // No referrers... - delete *I; - I = GlobalNodes.erase(I); // Remove the node... - Changed = true; + if ((*I)->getReferrers().empty()) { + GlobalDSNode *GDN = *I; + bool NoLinks = true; // Make sure there are no outgoing links... + for (unsigned i = 0, e = GDN->getNumLinks(); i != e; ++i) + if (!GDN->getLink(i).empty()) { + NoLinks = false; + break; + } + if (NoLinks) { + delete GDN; + I = GlobalNodes.erase(I); // Remove the node... + Changed = true; + } else { + ++I; + } } else { ++I; } + return Changed; } |