[llvm-commits] CVS: llvm/lib/Analysis/DataStructure/DataStructure.cpp

Chris Lattner lattner at cs.uiuc.edu
Wed Feb 25 17:09:00 PST 2004


Changes in directory llvm/lib/Analysis/DataStructure:

DataStructure.cpp updated: 1.158 -> 1.159

---
Log message:

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.


---
Diffs of the changes:  (+12 -10)

Index: llvm/lib/Analysis/DataStructure/DataStructure.cpp
diff -u llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.158 llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.159
--- llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.158	Sat Feb 21 18:53:54 2004
+++ llvm/lib/Analysis/DataStructure/DataStructure.cpp	Wed Feb 25 17:08:00 2004
@@ -1351,9 +1351,9 @@
 
   // 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 @@
   //
   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.





More information about the llvm-commits mailing list