[llvm-commits] CVS: llvm/include/llvm/Analysis/DSGraph.h DSNode.h

Chris Lattner lattner at cs.uiuc.edu
Sat Feb 7 19:28:44 PST 2004


Changes in directory llvm/include/llvm/Analysis:

DSGraph.h updated: 1.73 -> 1.74
DSNode.h updated: 1.38 -> 1.39

---
Log message:

Substantially improve the DSA code by removing 'forwarding' nodes from
DSGraphs while they are forwarding.  When the last reference to the forwarding
node is dropped, the forwarding node is autodeleted.  This should simplify
removeTriviallyDead nodes, and is only (efficiently) possible because we are 
using an ilist of dsnodes now.


---
Diffs of the changes:  (+9 -2)

Index: llvm/include/llvm/Analysis/DSGraph.h
diff -u llvm/include/llvm/Analysis/DSGraph.h:1.73 llvm/include/llvm/Analysis/DSGraph.h:1.74
--- llvm/include/llvm/Analysis/DSGraph.h:1.73	Sat Feb  7 18:53:07 2004
+++ llvm/include/llvm/Analysis/DSGraph.h	Sat Feb  7 19:27:13 2004
@@ -182,6 +182,7 @@
   /// addNode - Add a new node to the graph.
   ///
   void addNode(DSNode *N) { Nodes.push_back(N); }
+  void unlinkNode(DSNode *N) { Nodes.remove(N); }
 
   /// getScalarMap - Get a map that describes what the nodes the scalars in this
   /// function point to...


Index: llvm/include/llvm/Analysis/DSNode.h
diff -u llvm/include/llvm/Analysis/DSNode.h:1.38 llvm/include/llvm/Analysis/DSNode.h:1.39
--- llvm/include/llvm/Analysis/DSNode.h:1.38	Sat Feb  7 18:53:07 2004
+++ llvm/include/llvm/Analysis/DSNode.h	Sat Feb  7 19:27:13 2004
@@ -159,12 +159,18 @@
   DSNode *getForwardNode() const { return ForwardNH.getNode(); }
 
   /// isForwarding - Return true if this node is forwarding to another.
+  ///
   bool isForwarding() const { return !ForwardNH.isNull(); }
 
+  /// stopForwarding - When the last reference to this forwarding node has been
+  /// dropped, delete the node.
   void stopForwarding() {
     assert(isForwarding() &&
            "Node isn't forwarding, cannot stopForwarding!");
     ForwardNH.setNode(0);
+    assert(ParentGraph == 0 &&
+           "Forwarding nodes must have been removed from graph!");
+    delete this;
   }
 
   /// hasLink - Return true if this memory object has a link in slot #LinkNo
@@ -377,8 +383,8 @@
 }
 
 inline void DSNodeHandle::setNode(DSNode *n) const {
-  assert(!n || !n->getForwardNode() && "Cannot set node to a forwarded node!");
-  if (N) N->NumReferrers--;
+  assert(!n || !n->isForwarding() && "Cannot set node to a forwarded node!");
+  if (N) getNode()->NumReferrers--;
   N = n;
   if (N) {
     N->NumReferrers++;





More information about the llvm-commits mailing list