[PATCH] D38501: [ValueTracking] Fix a misuse of APInt in GetPointerBaseWithConstantOffset

Hal Finkel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 5 13:33:15 PDT 2017


hfinkel added inline comments.


================
Comment at: lib/Analysis/ValueTracking.cpp:3068
+      ByteOffset += GEPOffset.sextOrTrunc(ByteOffset.getBitWidth());
 
       Ptr = GEP->getPointerOperand();
----------------
We still need to make sure that the result doesn't overflow. I think something like this would work:

  APInt OrigByteOffset(ByteOffset);

  ByteOffset += GEPOffset.sextOrTrunc(ByteOffset.getBitWidth());
  if (ByteOffset.getActiveBits() >= 64) {
    ByteOffset = OrigByteOffset;
    break;
  }



https://reviews.llvm.org/D38501





More information about the llvm-commits mailing list