[LazyValueInfo] Report nonnull range for nonnull pointers
[oota-llvm.git] / lib / Analysis / LazyValueInfo.cpp
index 7fc3e5afe48341cf11ac4aa5ed837edb34909e51..795e3987c0d7498176890ab3e4ac61157d5bce17 100644 (file)
@@ -531,8 +531,10 @@ bool LazyValueInfoCache::solveBlockValue(Value *Val, BasicBlock *BB) {
     return true;
   }
 
-  if (AllocaInst *AI = dyn_cast<AllocaInst>(BBI)) {
-    Res = LVILatticeVal::getNot(ConstantPointerNull::get(AI->getType()));
+  // If this value is a nonnull pointer, record it's range and bailout.
+  PointerType *PT = dyn_cast<PointerType>(BBI->getType());
+  if (PT && isKnownNonNull(BBI)) {
+    Res = LVILatticeVal::getNot(ConstantPointerNull::get(PT));
     insertResult(Val, BB, Res);
     return true;
   }