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

Johannes Doerfert via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 27 10:50:15 PST 2018


jdoerfert marked 2 inline comments as done.
jdoerfert added a comment.

I'm also running the LLVM-TS to check nothing breaks.



================
Comment at: lib/Analysis/ValueTracking.cpp:2028
+
+    if (const AddrSpaceCastInst *ASC = dyn_cast<AddrSpaceCastInst>(V))
+      return isKnownNonZero(ASC->getPointerOperand(), Depth, Q);
----------------
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.


================
Comment at: lib/Analysis/ValueTracking.cpp:2031
+
+    if (const PtrToIntOperator *P2I = dyn_cast<PtrToIntOperator>(V))
+      return isKnownNonZero(P2I->getPointerOperand(), Depth, Q);
----------------
fhahn wrote:
> ptrtoint & inttoptr do truncate if the target type is smaller than the value type. Wouldn't it be possible that this changes a non-zero value to a zero value ( if we truncate all non-zero bits?)
Agreed again, I'll add size checks for these.


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