mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-02 19:24:25 +00:00
* 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
This commit is contained in:
@ -19,6 +19,8 @@
|
|||||||
#include "Support/STLExtras.h"
|
#include "Support/STLExtras.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
//#define DEBUG_NODE_ELIMINATE 1
|
||||||
|
|
||||||
// NodesAreEquivalent - Check to see if the nodes are equivalent in all ways
|
// 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
|
// except node type. Since we know N1 is a shadow node, N2 is allowed to be
|
||||||
// any type.
|
// 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!");
|
assert(N1 != N2 && "A node is always equivalent to itself!");
|
||||||
|
|
||||||
// Perform simple, fast checks first...
|
// Perform simple, fast checks first...
|
||||||
if (N1->getType() != N2->getType()) return false;
|
if (N1->getType() != N2->getType() || // Must have same type...
|
||||||
assert(N1->getNumLinks() == N2->getNumLinks() && "Same type, diff # links?");
|
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
|
// The shadow node is considered equivalent if it has a subset of the incoming
|
||||||
// edges that N2 does...
|
// edges that N2 does...
|
||||||
@ -51,6 +58,7 @@ static bool NodesAreEquivalent(const ShadowDSNode *N1, const DSNode *N2) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return i1 == e1 && i2 <= e2;
|
return i1 == e1 && i2 <= e2;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// IndistinguishableShadowNode - A shadow node is indistinguishable if some
|
// IndistinguishableShadowNode - A shadow node is indistinguishable if some
|
||||||
@ -77,13 +85,6 @@ static bool IndistinguishableShadowNode(const ShadowDSNode *SN) {
|
|||||||
return false;
|
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
|
// UnlinkUndistinguishableShadowNodes - Eliminate shadow nodes that are not
|
||||||
// distinguishable from some other node in the graph...
|
// distinguishable from some other node in the graph...
|
||||||
@ -96,10 +97,12 @@ bool FunctionDSGraph::UnlinkUndistinguishableShadowNodes() {
|
|||||||
for (vector<ShadowDSNode*>::iterator I = ShadowNodes.begin();
|
for (vector<ShadowDSNode*>::iterator I = ShadowNodes.begin();
|
||||||
I != ShadowNodes.end(); )
|
I != ShadowNodes.end(); )
|
||||||
if (IndistinguishableShadowNode(*I)) {
|
if (IndistinguishableShadowNode(*I)) {
|
||||||
|
#ifdef DEBUG_NODE_ELIMINATE
|
||||||
cerr << "Found Indistinguishable Shadow Node:\n";
|
cerr << "Found Indistinguishable Shadow Node:\n";
|
||||||
(*I)->print(cerr);
|
(*I)->print(cerr);
|
||||||
removeEdgesTo(*I);
|
#endif
|
||||||
// Don't need to dropAllRefs, because nothing can poitn to it now
|
(*I)->removeAllIncomingEdges();
|
||||||
|
// Don't need to dropAllRefs, because nothing can point to it now
|
||||||
delete *I;
|
delete *I;
|
||||||
|
|
||||||
I = ShadowNodes.erase(I);
|
I = ShadowNodes.erase(I);
|
||||||
@ -180,7 +183,7 @@ bool FunctionDSGraph::RemoveUnreachableShadowNodes() {
|
|||||||
for (unsigned i = 0; i != ShadowNodes.size(); ++i)
|
for (unsigned i = 0; i != ShadowNodes.size(); ++i)
|
||||||
if (!Reachable[i]) {
|
if (!Reachable[i]) {
|
||||||
// Track all unreachable nodes...
|
// Track all unreachable nodes...
|
||||||
#if 0
|
#if DEBUG_NODE_ELIMINATE
|
||||||
cerr << "Unreachable node eliminated:\n";
|
cerr << "Unreachable node eliminated:\n";
|
||||||
ShadowNodes[i]->print(cerr);
|
ShadowNodes[i]->print(cerr);
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user