diff options
| author | Dan Gohman <gohman@apple.com> | 2010-07-28 17:11:36 +0000 |
|---|---|---|
| committer | Dan Gohman <gohman@apple.com> | 2010-07-28 17:11:36 +0000 |
| commit | 32f889e552d5964c43ebc27385c2a79fb21fd74a (patch) | |
| tree | 47d4f80a5c97e9f0d628455dc9bb57a326559160 | |
| parent | 44ee74292f039de0d1f4706be2d6be16a6da939d (diff) | |
| download | bcm5719-llvm-32f889e552d5964c43ebc27385c2a79fb21fd74a.tar.gz bcm5719-llvm-32f889e552d5964c43ebc27385c2a79fb21fd74a.zip | |
Do GEP offset calculations with unsigned math rather than signed math
to avoid undefined behavior on overflow, noticed by John Regehr.
llvm-svn: 109594
| -rw-r--r-- | llvm/lib/Target/TargetData.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/llvm/lib/Target/TargetData.cpp b/llvm/lib/Target/TargetData.cpp index 9b207c1f28c..65f514c2647 100644 --- a/llvm/lib/Target/TargetData.cpp +++ b/llvm/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); } } |

