[PATCH] D99642: For non-null pointer checks, do not descend through out-of-bounds GEPs

Momchil Velikov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 7 08:48:16 PDT 2021


chill marked 3 inline comments as done.
chill added a comment.

In D99642#2660895 <https://reviews.llvm.org/D99642#2660895>, @nikic wrote:

> I think this should be using `Val->stripInBoundsOffsets()` rather than modify the `getUnderlyingObject()` API.

Thanks, indeed!



================
Comment at: llvm/lib/Analysis/ValueTracking.cpp:4275
     if (auto *GEP = dyn_cast<GEPOperator>(V)) {
+      if (InBounds && !GEP->isInBounds())
+        return V;
----------------
nlopes wrote:
> fhahn wrote:
> > According to https://llvm.org/docs/LangRef.html#pointer-aliasing-rules, `inbounds` should not impact the underlying object property IIUC. But probably can only rely on that, if the pointer gets actually dereferenced? 
> Agreed. GEP doesn't change the object even without inbounds.
Yeah, it was just my clumsy attempt to reuse the implementation (`InBounds`param was defaulted to `false`).


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D99642/new/

https://reviews.llvm.org/D99642



More information about the llvm-commits mailing list