[PATCH] D38337: Check for overflows when calculating the offset in GetGEPCost.

Justin Lebar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 27 16:14:12 PDT 2017


jlebar added inline comments.


================
Comment at: llvm/include/llvm/Analysis/TargetTransformInfoImpl.h:707
+          BaseOffset +=
+              APInt(PtrSizeBits, ConstIdx->getSExtValue()) * ElementSize;
+        } else {
----------------
efriedma wrote:
> `ConstIdx->getValue().sextOrTrunc(PtrSizeBits)`?  getSExtValue() can fail if ConstIdx is, for example, an i128.
Indeed.  Fixed, and added a testcase.


https://reviews.llvm.org/D38337





More information about the llvm-commits mailing list