[PATCH] D54956: [ValueTracking] Look through casts when determining non-nullness

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 27 13:34:04 PST 2018


spatel added inline comments.


================
Comment at: lib/Analysis/ValueTracking.cpp:2028
+
+    if (const AddrSpaceCastInst *ASC = dyn_cast<AddrSpaceCastInst>(V))
+      return isKnownNonZero(ASC->getPointerOperand(), Depth, Q);
----------------
fhahn wrote:
> jdoerfert wrote:
> > fhahn wrote:
> > > Not sure if that is safe, according to LangRef: `The ‘addrspacecast’ instruction converts the pointer value ptrval to type pty2. It can be a no-op cast or a complex value modification, depending on the target and the address space pair.`
> > Agreed, I'll remove this again.
> I think it would be worth adding a separate file to test the various combinations of supported/unsupported casts.
+1. If we almost got the logic wrong in this patch, we should have some negative tests to make sure someone doesn't come here in the future and extend it wrongly. A code comment would be good too.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D54956





More information about the llvm-commits mailing list