projects
/
oota-llvm.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
dc7a235
)
Do GEP offset calculations with unsigned math rather than signed math
author
Dan Gohman
<gohman@apple.com>
Wed, 28 Jul 2010 17:11:36 +0000
(17:11 +0000)
committer
Dan Gohman
<gohman@apple.com>
Wed, 28 Jul 2010 17:11:36 +0000
(17:11 +0000)
to avoid undefined behavior on overflow, noticed by John Regehr.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@109594
91177308
-0d34-0410-b5e6-
96231b3b80d8
lib/Target/TargetData.cpp
patch
|
blob
|
history
diff --git
a/lib/Target/TargetData.cpp
b/lib/Target/TargetData.cpp
index 9b207c1f28cf2645eb2c2492178fc7fc0d5be40f..65f514c26474e8e021f122b7465dab6f9d5ba9da 100644
(file)
--- a/
lib/Target/TargetData.cpp
+++ b/
lib/Target/TargetData.cpp
@@
-625,7
+625,7
@@
uint64_t TargetData::getIndexedOffset(const Type *ptrTy, Value* const* Indices,
// Get the array index and the size of each array element.
if (int64_t arrayIdx = cast<ConstantInt>(Indices[CurIDX])->getSExtValue())
- Result +=
arrayIdx * (int64_t)
getTypeAllocSize(Ty);
+ Result +=
(uint64_t)arrayIdx *
getTypeAllocSize(Ty);
}
}