From 62f8bf05668db841c44afb2977e785cac9e4dfd3 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 20 Jan 2004 19:13:07 +0000 Subject: [PATCH] Fix PR212 - Bytecode reader misreads 'long -9223372036854775808'! Fix testcase test/Regression/Assembler/2004-01-20-MaxLongLong.llx git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10928 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Bytecode/Reader/ReaderPrimitives.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/Bytecode/Reader/ReaderPrimitives.h b/lib/Bytecode/Reader/ReaderPrimitives.h index 0366ee3a792..496ab2a5b13 100644 --- a/lib/Bytecode/Reader/ReaderPrimitives.h +++ b/lib/Bytecode/Reader/ReaderPrimitives.h @@ -59,9 +59,13 @@ namespace llvm { 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); } -- 2.34.1