[llvm-commits] [llvm] r49953 - in /llvm/branches/ggreif/use-diet: include/llvm/User.h lib/VMCore/Use.cpp

Gabor Greif ggreif at gmail.com
Sat Apr 19 10:13:45 PDT 2008


Author: ggreif
Date: Sat Apr 19 12:13:44 2008
New Revision: 49953

URL: http://llvm.org/viewvc/llvm-project?rev=49953&view=rev
Log:
update documentation, fix a bug in initTags and make the Use::zap method more performant

Modified:
    llvm/branches/ggreif/use-diet/include/llvm/User.h
    llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp

Modified: llvm/branches/ggreif/use-diet/include/llvm/User.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/User.h?rev=49953&r1=49952&r2=49953&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/include/llvm/User.h (original)
+++ llvm/branches/ggreif/use-diet/include/llvm/User.h Sat Apr 19 12:13:44 2008
@@ -62,7 +62,7 @@
 #  by the Use[] array.
 #      
 #      ...---.---.---.---.-------...
-#        | V | V | V | V | User
+#        | P | P | P | P | User
 #      '''---'---'---'---'-------'''
 
 
@@ -74,18 +74,18 @@
 #          |
 #          v
 #          .---.---.---.---...
-#          | V | V | V | V |
+#          | P | P | P | P |
 #          '---'---'---'---'''
 
-   (In the above figures 'V' stands for the Value* that
-    is stored in each Use object)
+   (In the above figures 'P' stands for the Use** that
+    is stored in each Use object in the member Use::Prev)
 
 
 Since the Use objects will be deprived of the direct pointer to
 their User objects, there must be a fast and exact method to
 recover it. This is accomplished by the following scheme:
 
-A bit-encoding in the 2 LSBits of the Use::Val will allow to find the
+A bit-encoding in the 2 LSBits of the Use::Prev will allow to find the
 start of the User object:
 
 00 --> binary digit 0
@@ -176,12 +176,12 @@
 OK, passed 500 tests.
 
 
-To maintain the invariant that the 2 LSBits of each Value* in Use
-never change after being set up, setters of Use::Val must re-tag the
-new Value* on every modification. Accordingly getters must strip the
+To maintain the invariant that the 2 LSBits of each Use** in Use
+never change after being set up, setters of Use::Prev must re-tag the
+new Use** on every modification. Accordingly getters must strip the
 tag bits.
 
-For layout b) instead of the User we will find a pointer (with LSBit set).
+For layout b) instead of the User we will find a pointer (User* with LSBit set).
 Following this pointer brings us to the User. A portable trick will ensure
 that the first bytes of User (if interpreted as a pointer) will never have
 the LSBit set.

Modified: llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp?rev=49953&r1=49952&r2=49953&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp (original)
+++ llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp Sat Apr 19 12:13:44 2008
@@ -51,7 +51,7 @@
 //===----------------------------------------------------------------------===//
 
 Use *Use::initTags(Use * const Start, Use *Stop, ptrdiff_t Done) {
-  ptrdiff_t Count = 0;
+  ptrdiff_t Count = Done;
   while (Start != Stop) {
     --Stop;
     Stop->Val = 0;
@@ -74,12 +74,17 @@
 //===----------------------------------------------------------------------===//
 
 void Use::zap(Use *Start, const Use *Stop, bool del) {
-  Use *Iter = Start;
-  while (Iter != Stop) {
-    (Iter++)->set(0);
-  }
-  if (del)
+  if (del) {
+    while (Start != Stop) {
+      (--Stop)->~Use();
+    }
     ::operator delete(Start);
+    return;
+  }
+
+  while (Start != Stop) {
+    (Start++)->set(0);
+  }
 }
 
 //===----------------------------------------------------------------------===//





More information about the llvm-commits mailing list