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

Chris Lattner lattner at cs.uiuc.edu
Tue Nov 12 01:21:01 PST 2002


Changes in directory llvm/lib/Analysis/DataStructure:

DataStructure.cpp updated: 1.66 -> 1.67

---
Log message:

Fix two bugs:
 * The globals vector was getting broken and unsorted, this caused vortex
   to get badly pessimized
 * Node offset handling was being handled really poorly, and in particular
   we were not merging types with offsets right.  This causes several graphs
   to be non-merged.


---
Diffs of the changes:

Index: llvm/lib/Analysis/DataStructure/DataStructure.cpp
diff -u llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.66 llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.67
--- llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.66	Mon Nov 11 15:35:38 2002
+++ llvm/lib/Analysis/DataStructure/DataStructure.cpp	Tue Nov 12 01:20:45 2002
@@ -341,9 +341,9 @@
     T Tmp = Dest[0];                      // Save value in temporary...
     Dest = Src;                           // Copy over list...
     typename vector<T>::iterator I =
-      std::lower_bound(Dest.begin(), Dest.end(),Tmp);
-    if (I == Dest.end() || *I != Src[0])  // If not already contained...
-      Dest.insert(I, Src[0]);
+      std::lower_bound(Dest.begin(), Dest.end(), Tmp);
+    if (I == Dest.end() || *I != Tmp)     // If not already contained...
+      Dest.insert(I, Tmp);
 
   } else {
     // Make a copy to the side of Dest...
@@ -387,9 +387,28 @@
     return;
   }
 
+  // If both nodes are not at offset 0, make sure that we are merging the node
+  // at an later offset into the node with the zero offset.
+  //
+  if (Offset < NH.getOffset()) {
+    N->mergeWith(DSNodeHandle(this, Offset), NH.getOffset());
+    return;
+  } else if (Offset == NH.getOffset() && getSize() < N->getSize()) {
+    // If the offsets are the same, merge the smaller node into the bigger node
+    N->mergeWith(DSNodeHandle(this, Offset), NH.getOffset());
+    return;
+  }
+
+  // Now we know that Offset >= NH.Offset, so convert it so our "Offset" (with
+  // respect to NH.Offset) is now zero.  NOffset is the distance from the base
+  // of our object that N starts from.
+  //
+  unsigned NOffset = Offset-NH.getOffset();
+  unsigned NSize = N->getSize();
+
   // Merge the type entries of the two nodes together...
   if (N->Ty.Ty != Type::VoidTy) {
-    mergeTypeInfo(N->Ty.Ty, Offset);
+    mergeTypeInfo(N->Ty.Ty, NOffset);
 
     // mergeTypeInfo can cause collapsing, which can cause this node to become
     // dead.
@@ -404,44 +423,25 @@
     if (!N->isNodeCompletelyFolded()) {
       N->foldNodeCompletely();
       if (hasNoReferrers()) return;
+       NSize = N->getSize();
     }
   } else if (N->isNodeCompletelyFolded()) {
     foldNodeCompletely();
-    Offset = 0;
     if (hasNoReferrers()) return;
+    Offset = 0;
+    NOffset = NH.getOffset();
+     NSize = N->getSize();
   }
   N = NH.getNode();
-  assert((NodeType & DSNode::DEAD) == 0);
-
   if (this == N || N == 0) return;
   assert((NodeType & DSNode::DEAD) == 0);
 
-  // If both nodes are not at offset 0, make sure that we are merging the node
-  // at an later offset into the node with the zero offset.
-  //
-  if (Offset > NH.getOffset()) {
-    N->mergeWith(DSNodeHandle(this, Offset), NH.getOffset());
-    return;
-  } else if (Offset == NH.getOffset() && getSize() < N->getSize()) {
-    // If the offsets are the same, merge the smaller node into the bigger node
-    N->mergeWith(DSNodeHandle(this, Offset), NH.getOffset());
-    return;
-  }
-
 #if 0
   std::cerr << "\n\nMerging:\n";
   N->print(std::cerr, 0);
   std::cerr << " and:\n";
   print(std::cerr, 0);
 #endif
-
-  // Now we know that Offset <= NH.Offset, so convert it so our "Offset" (with
-  // respect to NH.Offset) is now zero.
-  //
-  unsigned NOffset = NH.getOffset()-Offset;
-  unsigned NSize = N->getSize();
-
-  assert((NodeType & DSNode::DEAD) == 0);
 
   // Remove all edges pointing at N, causing them to point to 'this' instead.
   // Make sure to adjust their offset, not just the node pointer.





More information about the llvm-commits mailing list