[llvm-commits] [llvm] r109594 - /llvm/trunk/lib/Target/TargetData.cpp
Dan Gohman
gohman at apple.com
Wed Jul 28 10:11:36 PDT 2010
Author: djg
Date: Wed Jul 28 12:11:36 2010
New Revision: 109594
URL: http://llvm.org/viewvc/llvm-project?rev=109594&view=rev
Log:
Do GEP offset calculations with unsigned math rather than signed math
to avoid undefined behavior on overflow, noticed by John Regehr.
Modified:
llvm/trunk/lib/Target/TargetData.cpp
Modified: llvm/trunk/lib/Target/TargetData.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetData.cpp?rev=109594&r1=109593&r2=109594&view=diff
==============================================================================
--- llvm/trunk/lib/Target/TargetData.cpp (original)
+++ llvm/trunk/lib/Target/TargetData.cpp Wed Jul 28 12:11:36 2010
@@ -625,7 +625,7 @@
// 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);
}
}
More information about the llvm-commits
mailing list