summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-08-03 16:57:03 +0000
committerChris Lattner <sabre@nondot.org>2010-08-03 16:57:03 +0000
commit79102d97256daf3cd9ce4e468883af6e7bced09f (patch)
treea97cf140c5149a2a18c717672bbf29a3cd60e2d9 /llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
parent278008f5460f54be1fcde8d83076b248a6d417b8 (diff)
downloadbcm5719-llvm-79102d97256daf3cd9ce4e468883af6e7bced09f.tar.gz
bcm5719-llvm-79102d97256daf3cd9ce4e468883af6e7bced09f.zip
avoid undefined behavior negating minint.
llvm-svn: 110117
Diffstat (limited to 'llvm/lib/Bitcode/Writer/BitcodeWriter.cpp')
-rw-r--r--llvm/lib/Bitcode/Writer/BitcodeWriter.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
index 93ca8cdaacd..776c2d4495c 100644
--- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -735,8 +735,8 @@ static void WriteConstants(unsigned FirstVal, unsigned LastVal,
Code = bitc::CST_CODE_UNDEF;
} else if (const ConstantInt *IV = dyn_cast<ConstantInt>(C)) {
if (IV->getBitWidth() <= 64) {
- int64_t V = IV->getSExtValue();
- if (V >= 0)
+ uint64_t V = IV->getSExtValue();
+ if ((int64_t)V >= 0)
Record.push_back(V << 1);
else
Record.push_back((-V << 1) | 1);
OpenPOWER on IntegriCloud