Changed implementation of Serialize::EmitDiffPtrID and
authorTed Kremenek <kremenek@apple.com>
Sat, 17 Nov 2007 00:45:37 +0000 (00:45 +0000)
committerTed Kremenek <kremenek@apple.com>
Sat, 17 Nov 2007 00:45:37 +0000 (00:45 +0000)
Deserialize::ReadDiffPtrID to read and emit bools instead of unsigned
integers. This should result in a nice space optimization once we have
"auto-abbreviation" generation in place.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44200 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Bitcode/Deserialize.h
include/llvm/Bitcode/Serialize.h

index 46b111f8929ceacd82735c7af3d82d0ba32c4320..ef25da71409e24f4fb3280f4a00ed126f2633c36 100644 (file)
@@ -141,8 +141,8 @@ public:
   SerializedPtrID ReadPtrID() { return (SerializedPtrID) ReadInt(); }
 
   SerializedPtrID ReadDiffPtrID(SerializedPtrID& PrevID) {
-    unsigned x = ReadInt();    
-    return (SerializedPtrID) (x ? (PrevID+x) : 0);
+    bool x = ReadBool();    
+    return (SerializedPtrID) (x ? (PrevID+1) : 0);
   }
   
   
index 8db377946c4e7a47caffeb0492c8b4f3a754d00e..9430bb10a42eb6e081e7053c8554ee1bee394a5a 100644 (file)
@@ -57,10 +57,11 @@ public:
     SerializedPtrID ptr_id = getPtrId(ptr);
 
     if (ptr_id == 0)
-      EmitInt(0);
+      EmitBool(false);
     else {
       assert (ptr_id > PrevID);
-      EmitInt(ptr_id-PrevID);
+      assert (PrevID == 0 || ptr_id - PrevID == 1);
+      EmitBool(true);
     }
     
     return ptr_id;