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

Johannes Doerfert via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 29 09:58:30 PDT 2019


jdoerfert created this revision.
Herald added subscribers: llvm-commits, bollu, hiraditya.
Herald added a project: LLVM.

WIP!


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69571

Files:
  llvm/lib/Analysis/ValueTracking.cpp


Index: llvm/lib/Analysis/ValueTracking.cpp
===================================================================
--- llvm/lib/Analysis/ValueTracking.cpp
+++ llvm/lib/Analysis/ValueTracking.cpp
@@ -1902,8 +1902,7 @@
 static bool isKnownNonNullFromDominatingCondition(const Value *V,
                                                   const Instruction *CtxI,
                                                   const DominatorTree *DT) {
-  assert(V->getType()->isPointerTy() && "V must be pointer type");
-  assert(!isa<ConstantData>(V) && "Did not expect ConstantPointerNull");
+  assert(!isa<Constant>(V) && "Did not expect a constant!");
 
   if (!CtxI || !DT)
     return false;
@@ -2078,12 +2077,11 @@
     }
   }
 
+  if (isKnownNonNullFromDominatingCondition(V, Q.CxtI, Q.DT))
+    return true;
 
   // Check for recursive pointer simplifications.
   if (V->getType()->isPointerTy()) {
-    if (isKnownNonNullFromDominatingCondition(V, Q.CxtI, Q.DT))
-      return true;
-
     // Look through bitcast operations, GEPs, and int2ptr instructions as they
     // do not alter the value, or at least not the nullness property of the
     // value, e.g., int2ptr is allowed to zero/sign extend the value.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69571.226923.patch
Type: text/x-patch
Size: 1205 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191029/604b69ea/attachment.bin>


More information about the llvm-commits mailing list