summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Bytecode
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-01-20 19:13:07 +0000
committerChris Lattner <sabre@nondot.org>2004-01-20 19:13:07 +0000
commit467d9778686bfaf501e1cdd1401e956f91e2d34f (patch)
tree495cfbe2b1839a438d559b6668109eaaad51dc1b /llvm/lib/Bytecode
parent32afecc336ab1ba886bb44e9c65cdfdefe586d7e (diff)
downloadbcm5719-llvm-467d9778686bfaf501e1cdd1401e956f91e2d34f.tar.gz
bcm5719-llvm-467d9778686bfaf501e1cdd1401e956f91e2d34f.zip
Fix PR212 - Bytecode reader misreads 'long -9223372036854775808'!
Fix testcase test/Regression/Assembler/2004-01-20-MaxLongLong.llx llvm-svn: 10928
Diffstat (limited to 'llvm/lib/Bytecode')
-rw-r--r--llvm/lib/Bytecode/Reader/ReaderPrimitives.h10
1 files changed, 7 insertions, 3 deletions
diff --git a/llvm/lib/Bytecode/Reader/ReaderPrimitives.h b/llvm/lib/Bytecode/Reader/ReaderPrimitives.h
index 0366ee3a792..496ab2a5b13 100644
--- a/llvm/lib/Bytecode/Reader/ReaderPrimitives.h
+++ b/llvm/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);
}
OpenPOWER on IntegriCloud