aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-02-25 23:08:00 +0000
committerChris Lattner <sabre@nondot.org>2004-02-25 23:08:00 +0000
commit51c06abbf17474852d53c2264bbae375ad7337e2 (patch)
tree3dfe255fe856cc5816f486286e5cc49323590031
parent52fc8d7ec901c851762c3b1722d4b239ef1cb1fa (diff)
Simplify the dead node elimination stuff
Make the incompleteness marker faster by looping directly over the globals instead of over the scalars to find the globals Fix a bug where we didn't mark a global incomplete if it didn't have any outgoing edges. This wouldn't break any current clients but is still wrong. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11848 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Analysis/DataStructure/DataStructure.cpp22
1 files changed, 12 insertions, 10 deletions
diff --git a/lib/Analysis/DataStructure/DataStructure.cpp b/lib/Analysis/DataStructure/DataStructure.cpp
index 5ea414e208..3339d6152f 100644
--- a/lib/Analysis/DataStructure/DataStructure.cpp
+++ b/lib/Analysis/DataStructure/DataStructure.cpp
@@ -1351,9 +1351,9 @@ void DSGraph::markIncompleteNodes(unsigned Flags) {
// Mark all global nodes as incomplete...
if ((Flags & DSGraph::IgnoreGlobals) == 0)
- for (node_iterator NI = node_begin(), E = node_end(); NI != E; ++NI)
- if ((*NI)->isGlobalNode() && (*NI)->getNumLinks())
- markIncompleteNode(*NI);
+ for (DSScalarMap::global_iterator I = ScalarMap.global_begin(),
+ E = ScalarMap.global_end(); I != E; ++I)
+ markIncompleteNode(ScalarMap[*I].getNode());
}
static inline void killIfUselessEdge(DSNodeHandle &Edge) {
@@ -1773,16 +1773,18 @@ void DSGraph::removeDeadNodes(unsigned Flags) {
//
std::vector<DSNode*> DeadNodes;
DeadNodes.reserve(Nodes.size());
- for (NodeListTy::iterator NI = Nodes.begin(), E = Nodes.end(); NI != E;)
- if (!Alive.count(NI)) {
- ++NumDNE;
- DSNode *N = Nodes.remove(NI++);
+ for (NodeListTy::iterator NI = Nodes.begin(), E = Nodes.end(); NI != E;) {
+ DSNode *N = NI++;
+ assert(!N->isForwarding() && "Forwarded node in nodes list?");
+
+ if (!Alive.count(N)) {
+ Nodes.remove(N);
+ assert(!N->isForwarding() && "Cannot remove a forwarding node!");
DeadNodes.push_back(N);
N->dropAllReferences();
- } else {
- assert(NI->getForwardNode() == 0 && "Alive forwarded node?");
- ++NI;
+ ++NumDNE;
}
+ }
// Remove all unreachable globals from the ScalarMap.
// If flag RemoveUnreachableGlobals is set, GlobalNodes has only dead nodes.