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

Chris Lattner lattner at cs.uiuc.edu
Wed Jul 7 01:14:01 PDT 2004


Changes in directory llvm/lib/Analysis/DataStructure:

DataStructure.cpp updated: 1.175 -> 1.176
Local.cpp updated: 1.105 -> 1.106

---
Log message:

As much as I hate to say it, the whole setNode interface for DSNodeHandles
is HOPELESSLY broken.  The problem is that the embedded getNode call can
change the offset of the node handle in unpredictable ways.

As it turns out, all of the clients of this method really want to set
both the node and the offset, thus it is more efficient (and less buggy)
to just do both of them in one method call.  This fixes some obscure bugs
handling non-forwarded node handles.


---
Diffs of the changes:  (+7 -11)

Index: llvm/lib/Analysis/DataStructure/DataStructure.cpp
diff -u llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.175 llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.176
--- llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.175	Wed Jun 23 01:29:59 2004
+++ llvm/lib/Analysis/DataStructure/DataStructure.cpp	Wed Jul  7 01:12:51 2004
@@ -120,8 +120,7 @@
   if (To->Size <= 1) Offset = 0;
   assert((Offset < To->Size || (Offset == To->Size && Offset == 0)) &&
          "Forwarded offset is wrong!");
-  ForwardNH.setNode(To);
-  ForwardNH.setOffset(Offset);
+  ForwardNH.setTo(To, Offset);
   NodeType = DEAD;
   Size = 0;
   Ty = Type::VoidTy;
@@ -1096,10 +1095,9 @@
   for (unsigned i = 0, e = Links.size(); i != e; ++i)
     if (DSNode *N = Links[i].getNode()) {
       DSGraph::NodeMapTy::const_iterator ONMI = OldNodeMap.find(N);
-      if (ONMI != OldNodeMap.end()) {
-        Links[i].setNode(ONMI->second.getNode());
-        Links[i].setOffset(Links[i].getOffset()+ONMI->second.getOffset());
-      }
+      if (ONMI != OldNodeMap.end())
+        Links[i].setTo(ONMI->second.getNode(),
+                       Links[i].getOffset()+ONMI->second.getOffset());
     }
 }
 
@@ -1475,7 +1473,7 @@
       // No interesting info?
       if ((N->getNodeFlags() & ~DSNode::Incomplete) == 0 &&
           N->getType() == Type::VoidTy && !N->isNodeCompletelyFolded())
-        Edge.setNode(0);  // Kill the edge!
+        Edge.setTo(0, 0);  // Kill the edge!
 }
 
 static inline bool nodeContainsExternalFunction(const DSNode *N) {
@@ -1979,8 +1977,7 @@
     return;
   }
   
-  Entry.setNode(N2);
-  Entry.setOffset(NH2.getOffset()-NH1.getOffset());
+  Entry.setTo(N2, NH2.getOffset()-NH1.getOffset());
 
   // Loop over all of the fields that N1 and N2 have in common, recursively
   // mapping the edges together now.


Index: llvm/lib/Analysis/DataStructure/Local.cpp
diff -u llvm/lib/Analysis/DataStructure/Local.cpp:1.105 llvm/lib/Analysis/DataStructure/Local.cpp:1.106
--- llvm/lib/Analysis/DataStructure/Local.cpp:1.105	Sun Jul  4 07:19:55 2004
+++ llvm/lib/Analysis/DataStructure/Local.cpp	Wed Jul  7 01:12:52 2004
@@ -259,8 +259,7 @@
     N = createNode();
   }
 
-  NH.setNode(N);      // Remember that we are pointing to it...
-  NH.setOffset(0);
+  NH.setTo(N, 0);      // Remember that we are pointing to it...
   return NH;
 }
 





More information about the llvm-commits mailing list