[llvm-commits] CVS: llvm/lib/VMCore/Value.cpp

Chris Lattner lattner at cs.uiuc.edu
Tue Oct 8 18:48:00 PDT 2002


Changes in directory llvm/lib/VMCore:

Value.cpp updated: 1.27 -> 1.28

---
Log message:

Fix NASTY N^2 behavior that was causing the gzip benchmark to take forever to 
assemble.  Now we scan the use-list from the back when removing users instead 
of from the front.


---
Diffs of the changes:

Index: llvm/lib/VMCore/Value.cpp
diff -u llvm/lib/VMCore/Value.cpp:1.27 llvm/lib/VMCore/Value.cpp:1.28
--- llvm/lib/VMCore/Value.cpp:1.27	Sun Sep  8 13:59:35 2002
+++ llvm/lib/VMCore/Value.cpp	Tue Oct  8 18:46:55 2002
@@ -77,12 +77,18 @@
   Ty = NewTy;
 }
 
-void Value::killUse(User *i) {
-  if (i == 0) return;
-  use_iterator I = find(Uses.begin(), Uses.end(), i);
+void Value::killUse(User *U) {
+  if (U == 0) return;
+  unsigned i;
 
-  assert(I != Uses.end() && "Use not in uses list!!");
-  Uses.erase(I);
+  // Scan backwards through the uses list looking for the user.  We do this
+  // because vectors like to be accessed on the end.  This is incredibly
+  // important from a performance perspective.
+  for (i = Uses.size()-1; Uses[i] != U; --i)
+    /* empty */;
+
+  assert(i < Uses.size() && "Use not in uses list!!");
+  Uses.erase(Uses.begin()+i);
 }
 
 User *Value::use_remove(use_iterator &I) {





More information about the llvm-commits mailing list