[llvm-commits] CVS: llvm/lib/Bytecode/Reader/ReaderPrimitives.h

Chris Lattner lattner at cs.uiuc.edu
Tue Jan 20 13:14:01 PST 2004


Changes in directory llvm/lib/Bytecode/Reader:

ReaderPrimitives.h updated: 1.3 -> 1.4

---
Log message:

Fix PR212 - Bytecode reader misreads 'long -9223372036854775808'!
Fix testcase test/Regression/Assembler/2004-01-20-MaxLongLong.llx



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

Index: llvm/lib/Bytecode/Reader/ReaderPrimitives.h
diff -u llvm/lib/Bytecode/Reader/ReaderPrimitives.h:1.3 llvm/lib/Bytecode/Reader/ReaderPrimitives.h:1.4
--- llvm/lib/Bytecode/Reader/ReaderPrimitives.h:1.3	Thu Jan 15 00:13:09 2004
+++ llvm/lib/Bytecode/Reader/ReaderPrimitives.h	Tue Jan 20 13:13:07 2004
@@ -59,9 +59,13 @@
   static inline int64_t read_vbr_int64(const unsigned char *&Buf, 
                                        const unsigned char *EndBuf) {
     uint64_t R = read_vbr_uint64(Buf, EndBuf);
-    if (R & 1)
-      return -(int64_t)(R >> 1);
-    else
+    if (R & 1) {
+      if (R != 1)
+        return -(int64_t)(R >> 1);
+      else   // There is no such thing as -0 with integers.  "-0" really means
+             // 0x8000000000000000.
+        return 1LL << 63;
+    } else
       return  (int64_t)(R >> 1);
   }
   





More information about the llvm-commits mailing list