[PATCH] D69571: [ValueTracking] Allow context-sensitive nullness check for non-pointers

Johannes Doerfert via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 31 08:55:59 PDT 2019


jdoerfert marked an inline comment as done.
jdoerfert added inline comments.


================
Comment at: llvm/lib/Analysis/ValueTracking.cpp:1906
+  if (isa<Constant>(V))
+    return false;
 
----------------
lebedev.ri wrote:
> jdoerfert wrote:
> > nikic wrote:
> > > Why can't this be an assert? Looks like the Constant case is fully handled first in `isKnownNonZero()`.
> > I thought so too, run it, and caused the assert to trigger. The last case has two `if`s nested. That is already a way out of the first case, might be more.
> > 
> > I don't think we want to look at dominance of constants (for now) so I just return false. There is actually something we could do here, but hat is a different story.
> While there, should this be
> ```
>   if (isa<Constant>(V))
>     return isa<ConstantPointerNull>(V);
> ```
> ?
I don't think so, and unfortunately `!isa<ConstantPointerNull>` doesn't work either (but that would be closer). I was hoping that "easy" constants don't make it here and hard ones would need us to inspect the surrounding (and are unlikely anyway, e.g., globals with weak linkage)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69571





More information about the llvm-commits mailing list