aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/DataStructure/EliminateNodes.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-03-27 19:48:03 +0000
committerChris Lattner <sabre@nondot.org>2002-03-27 19:48:03 +0000
commit2ba3a72c3ae76f05a19889b6736ccfde541d6c66 (patch)
tree1af432ba5b6d6d9584d46b5b6ad67eab83d292a8 /lib/Analysis/DataStructure/EliminateNodes.cpp
parent6088c4f55e1ad0efefc0bc3739756ddbebf92899 (diff)
* Add #define to enabled debug messages
* Move removeEdgesTo to be a member of DSNode * Implement (but #ifdef out) the new, spiffier, method of determining shadow node equivalence. This cannot be enabled until more is implemented. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2004 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/DataStructure/EliminateNodes.cpp')
-rw-r--r--lib/Analysis/DataStructure/EliminateNodes.cpp27
1 files changed, 15 insertions, 12 deletions
diff --git a/lib/Analysis/DataStructure/EliminateNodes.cpp b/lib/Analysis/DataStructure/EliminateNodes.cpp
index a3234d1904..3d1319dcf2 100644
--- a/lib/Analysis/DataStructure/EliminateNodes.cpp
+++ b/lib/Analysis/DataStructure/EliminateNodes.cpp
@@ -19,6 +19,8 @@
#include "Support/STLExtras.h"
#include <algorithm>
+//#define DEBUG_NODE_ELIMINATE 1
+
// NodesAreEquivalent - Check to see if the nodes are equivalent in all ways
// except node type. Since we know N1 is a shadow node, N2 is allowed to be
// any type.
@@ -27,8 +29,13 @@ static bool NodesAreEquivalent(const ShadowDSNode *N1, const DSNode *N2) {
assert(N1 != N2 && "A node is always equivalent to itself!");
// Perform simple, fast checks first...
- if (N1->getType() != N2->getType()) return false;
- assert(N1->getNumLinks() == N2->getNumLinks() && "Same type, diff # links?");
+ if (N1->getType() != N2->getType() || // Must have same type...
+ N1->isCriticalNode()) // Must not be a critical node...
+ return false;
+
+#if 0
+ return true;
+#else
// The shadow node is considered equivalent if it has a subset of the incoming
// edges that N2 does...
@@ -51,6 +58,7 @@ static bool NodesAreEquivalent(const ShadowDSNode *N1, const DSNode *N2) {
}
return i1 == e1 && i2 <= e2;
+#endif
}
// IndistinguishableShadowNode - A shadow node is indistinguishable if some
@@ -77,13 +85,6 @@ static bool IndistinguishableShadowNode(const ShadowDSNode *SN) {
return false;
}
-// removeEdgesTo - Erase all edges in the graph that point to the specified node
-static void removeEdgesTo(DSNode *Node) {
- while (!Node->getReferrers().empty()) {
- PointerValSet *PVS = Node->getReferrers().back();
- PVS->removePointerTo(Node);
- }
-}
// UnlinkUndistinguishableShadowNodes - Eliminate shadow nodes that are not
// distinguishable from some other node in the graph...
@@ -96,10 +97,12 @@ bool FunctionDSGraph::UnlinkUndistinguishableShadowNodes() {
for (vector<ShadowDSNode*>::iterator I = ShadowNodes.begin();
I != ShadowNodes.end(); )
if (IndistinguishableShadowNode(*I)) {
+#ifdef DEBUG_NODE_ELIMINATE
cerr << "Found Indistinguishable Shadow Node:\n";
(*I)->print(cerr);
- removeEdgesTo(*I);
- // Don't need to dropAllRefs, because nothing can poitn to it now
+#endif
+ (*I)->removeAllIncomingEdges();
+ // Don't need to dropAllRefs, because nothing can point to it now
delete *I;
I = ShadowNodes.erase(I);
@@ -180,7 +183,7 @@ bool FunctionDSGraph::RemoveUnreachableShadowNodes() {
for (unsigned i = 0; i != ShadowNodes.size(); ++i)
if (!Reachable[i]) {
// Track all unreachable nodes...
-#if 0
+#if DEBUG_NODE_ELIMINATE
cerr << "Unreachable node eliminated:\n";
ShadowNodes[i]->print(cerr);
#endif